Skip to content

Commit 939464f

Browse files
committed
sync.interface: add
1 parent 6260b6c commit 939464f

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Import third-party types
3+
*/
4+
5+
import type { AnyAction } from 'redux';
6+
7+
/**
8+
* Initialization Events Type
9+
* These constants represent the events used for initializing the state.
10+
* `GET_INIT_STATE` is used to request the initial state from another tab.
11+
* `RECEIVE_INIT_STATE` is used to receive the initial state from another tab.
12+
*/
13+
14+
export const GET_INIT_STATE = '&_GET_INIT_STATE';
15+
export const RECEIVE_INIT_STATE = '&_RECEIVE_INIT_STATE';
16+
17+
/**
18+
* Synchronization configuration interface
19+
* This interface provides the options for configuring the synchronization of actions across multiple tabs.
20+
*
21+
* Note: When using multiple options (predicate, `blacklist`, and `whitelist`), only one of them will be effective.
22+
* The priority is `predicate` > `blacklist` > `whitelist`.
23+
*/
24+
25+
export interface ConfigSyncInterface {
26+
/**
27+
* Name of the communication channel to use for action synchronization.
28+
*/
29+
30+
channelName?: string;
31+
32+
/**
33+
* Flag indicating whether to copy the initial state from another tab (if available).
34+
*/
35+
36+
initState?: boolean;
37+
38+
/**
39+
* Array of actions that will not be triggered in other tabs.
40+
*/
41+
42+
blacklist?: string[];
43+
44+
/**
45+
* Array of actions that will be triggered in other tabs.
46+
*/
47+
48+
whitelist?: string[];
49+
50+
/**
51+
* A function to filter the actions to be synchronized based on custom criteria.
52+
*/
53+
54+
predicate?: (action: AnyAction) => boolean;
55+
56+
/**
57+
* A function to prepare the initial state for synchronization with other tabs.
58+
*/
59+
60+
prepareState?: (action: AnyAction) => any;
61+
}
62+

0 commit comments

Comments
 (0)