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
| Parameter | Type | Description |
|---|---|---|
player | Player | undefined | The player, or undefined before it has been created. |
Returns
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
| Parameter | Type | Description |
|---|---|---|
player | Player | undefined | The player, or undefined before it has been created. |
selector | PlayerStateSelector<T> | Pure projection of the snapshot. Must be cheap: it runs on every store read. |
isEqual? | (a: T, b: T) => boolean | Comparison 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.