@types/redux-state-sync
TypeScript icon, indicating that this package has built-in type declarations

3.1.10 • Public • Published

Installation

npm install --save @types/redux-state-sync

Summary

This package contains type definitions for redux-state-sync (https://github.com/AOHUA/redux-state-sync#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/redux-state-sync.

import BroadcastChannel, { BroadcastChannelOptions } from "broadcast-channel";
import { AnyAction, Middleware, Reducer, Store } from "redux";

export const GET_INIT_STATE = "&_GET_INIT_STATE";
export const SEND_INIT_STATE = "&_SEND_INIT_STATE";
export const RECEIVE_INIT_STATE = "&_RECEIVE_INIT_STATE";
export const INIT_MESSAGE_LISTENER = "&_INIT_MESSAGE_LISTENER";
export const WINDOW_STATE_SYNC_ID: string;

export interface Stamp {
    $uuid: string;
    $wuid: string;
    $isSync: boolean;
}
export type StampedAction = Stamp & AnyAction;

export interface Config {
    channel?: string | undefined;
    predicate?: ((action: AnyAction) => boolean | null) | undefined;
    blacklist?: string[] | undefined;
    whitelist?: string[] | undefined;
    broadcastChannelOption?: BroadcastChannelOptions | undefined;
    prepareState?: ((state: any) => any) | undefined;
    receiveState?: ((prevState: any, nextState: any) => any) | undefined;
}

export interface MessageListenerConfig {
    channel: BroadcastChannel;
    dispatch: (action: AnyAction | StampedAction) => void;
    allowed: (action: AnyAction) => boolean;
}

export function generateUuidForAction(action: AnyAction): StampedAction;
export function isActionAllowed(config: Config): (type: string) => boolean;
export function createMessageListener(config: MessageListenerConfig): void;
export function createStateSyncMiddleware(config?: Config): Middleware;
export function withReduxStateSync<T extends Reducer>(
    appReducer: T,
    prepareInitialStateForStore?: Config["receiveState"],
): T;
export function initStateWithPrevTab(store: Store): Store;
export function initMessageListener(store: Store): Store;
export function isActionSynced(action: AnyAction): boolean;

/** @deprecated Undocumented alias to withReduxStateSync */
export const createReduxStateSync: typeof withReduxStateSync;

Additional Details

Credits

These definitions were written by MU AOHUA.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/redux-state-sync

Weekly Downloads

18,377

Version

3.1.10

License

MIT

Unpacked Size

6.48 kB

Total Files

5

Last publish

Collaborators

  • types