Interface Store<State>Experimental

A store that has a state of type State. A store informs clients about state changes and publishes its state as a stable snapshot.

interface Store<State> {
    id: string;
    getSnapshot(): State;
    subscribe(onStoreChange): (() => void);
}

Type Parameters

  • State = unknown

    The type of state managed by this store.

Properties

Methods

Properties

id: string

The unique store identifier.

Methods

  • A function that returns a snapshot of the data in the store that’s needed by the component. While the store has not changed, repeated calls to getSnapshot must return the same value. If the store changes and the returned value is different (as compared by Object.is), React re-renders the component.

    Returns State

  • A function that takes a single callback argument onStoreChange and subscribes it to the store. When the store changes, it should invoke the provided callback. This will cause the component to re-render. The subscribe function should return a function that cleans up the subscription.

    Parameters

    • onStoreChange: (() => void)
        • (): void
        • Returns void

    Returns (() => void)

      • (): void
      • Returns void

Generated using TypeDoc