Skip to main content

Function: usePlayerState()

Call Signature

function usePlayerState(player: Player | undefined): PlayerState;

Defined in: packages/player/src/hooks/usePlayerState.ts:22

Subscribe to the whole player state.

Parameters

ParameterTypeDescription
playerPlayer | undefinedThe player, or undefined before it has been created.

Returns

PlayerState

The current immutable snapshot.

Call Signature

function usePlayerState<T>(
player: Player | undefined,
selector: PlayerStateSelector<T>,
isEqual?: (a: T, b: T) => boolean
): T;

Defined in: packages/player/src/hooks/usePlayerState.ts:38

Subscribe to a projection of the player state.

The component re-renders only when the selected value changes, which is the point: useProgress-style tickers aside, most UI cares about one or two fields.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
playerPlayer | undefinedThe player, or undefined before it has been created.
selectorPlayerStateSelector<T>Pure projection of the snapshot. Must be cheap: it runs on every store read.
isEqual?(a: T, b: T) => booleanComparison used to decide whether the selected value changed. Defaults to Object.is; pass a shallow comparison when the selector returns a fresh object.

Returns

T

The selected value.