mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(site): add util reference pipeline (#537)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
c11395ece1
commit
78112fbefd
@@ -3,7 +3,16 @@ import { type Comparator, type Selector, shallowEqual } from '../../core/shallow
|
||||
|
||||
export type { Comparator, Selector };
|
||||
|
||||
/** Subscribe to derived state with customizable equality check. */
|
||||
/**
|
||||
* Subscribe to derived state with customizable equality check.
|
||||
*
|
||||
* Low-level hook used internally by `useStore` and `useSnapshot`.
|
||||
*
|
||||
* @param subscribe - Subscribe function that returns an unsubscribe callback.
|
||||
* @param getSnapshot - Returns the current snapshot value.
|
||||
* @param selector - Derives a value from the snapshot.
|
||||
* @param isEqual - Custom equality function. Defaults to `shallowEqual`.
|
||||
*/
|
||||
export function useSelector<S, R>(
|
||||
subscribe: (cb: () => void) => () => void,
|
||||
getSnapshot: () => S,
|
||||
|
||||
@@ -2,9 +2,23 @@ import { identity } from '@videojs/utils/function';
|
||||
import type { State } from '../../core/state';
|
||||
import { type Comparator, type Selector, useSelector } from './use-selector';
|
||||
|
||||
/** Subscribe to a State container's current value. */
|
||||
/**
|
||||
* Subscribe to a State container's current value.
|
||||
*
|
||||
* @param state - The State container to subscribe to.
|
||||
* @param selector - Derives a value from state.
|
||||
* @param isEqual - Custom equality function. Defaults to `shallowEqual`.
|
||||
*/
|
||||
/** @label Without Selector */
|
||||
export function useSnapshot<T extends object>(state: State<T>): T;
|
||||
|
||||
/**
|
||||
* Select a value from state. Re-renders when the selected value changes.
|
||||
*
|
||||
* @label With Selector
|
||||
* @param selector - Derives a value from state.
|
||||
* @param isEqual - Custom equality function. Defaults to `shallowEqual`.
|
||||
*/
|
||||
export function useSnapshot<T extends object, R>(state: State<T>, selector: Selector<T, R>, isEqual?: Comparator<R>): R;
|
||||
|
||||
export function useSnapshot(state: State<object>, selector?: Selector<any, any>, isEqual?: Comparator<any>) {
|
||||
|
||||
@@ -24,8 +24,16 @@ const noopSubscribe = () => noop;
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
/** @label Without Selector */
|
||||
export function useStore<S extends AnyStore>(store: S): S;
|
||||
|
||||
/**
|
||||
* Select a value from the store. Re-renders when the selected value changes (shallowEqual).
|
||||
*
|
||||
* @label With Selector
|
||||
* @param selector - Derives a value from the store state.
|
||||
* @param isEqual - Custom equality function. Defaults to `shallowEqual`.
|
||||
*/
|
||||
export function useStore<S extends AnyStore, R>(
|
||||
store: S,
|
||||
selector: Selector<InferStoreState<S>, R>,
|
||||
|
||||
Reference in New Issue
Block a user