The SyncComponent class allows synchronization of Redux state between different tabs/windows in the same browser.

Hierarchy

  • SyncService

Constructors

  • Creates a new instance of SyncService.

    Throws

    Throws an error if the browser doesn't support cross-tab communication.

    Parameters

    Returns SyncService

Properties

allowed: ((action: AnyAction) => boolean)

Type declaration

    • (action: AnyAction): boolean
    • A function to check if a specific action is allowed.

      Parameters

      • action: AnyAction

      Returns boolean

channel: BroadcastChannel

The channel used for communication between tabs.

settings: any = ...

The default settings for the SyncComponent.

windowID: string = ...

The unique identifier of the current tab.

Methods

  • Sends a stamped action through the broadcast channel.

    Returns

    Throws

    If the browser doesn't support cross-tab communication.

    Parameters

    • stampedAction: any

      The stamped action to be sent.

    Returns void

  • Generates a unique identifier for the given action by adding a $wuid property with the current window ID.

    Returns

    • The stamped action object.

    Parameters

    • action: any

      The action to be stamped with a unique identifier.

    Returns AnyAction

  • Handle incoming messages from the broadcast channel and dispatch synced actions.

    Returns

    Parameters

    • event: MessageEvent<any>

      The message event object containing the action payload.

    Returns void

  • Private

    Initializes the state by dispatching an action to retrieve the initial state from other tabs.

    Returns

    Returns void

  • Checks whether the action is allowed based on the settings.

    Returns

    A function that takes an action and returns a boolean value indicating whether the action is allowed.

    Returns ((action: AnyAction) => boolean)

      • (action: AnyAction): boolean
      • Checks whether the action is allowed based on the settings.

        Returns

        A function that takes an action and returns a boolean value indicating whether the action is allowed.

        Parameters

        • action: AnyAction

        Returns boolean

Generated using TypeDoc