mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Update types for Redux-state-sync (#42979)
* update types * update test case * add test case * update version * update header Co-authored-by: aohua <aohua@percy.sg>
This commit is contained in:
parent
08b013bb1c
commit
0751ca13d0
7
types/redux-state-sync/index.d.ts
vendored
7
types/redux-state-sync/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for redux-state-sync 3.0
|
||||
// Type definitions for redux-state-sync 3.1
|
||||
// Project: https://github.com/AOHUA/redux-state-sync#readme
|
||||
// Definitions by: MU AOHUA <https://github.com/AOHUA>
|
||||
// AntonioMendez <https://github.com/AntonioMendez>
|
||||
@ -21,6 +21,7 @@ export interface Config {
|
||||
blacklist?: string[];
|
||||
whitelist?: string[];
|
||||
broadcastChannelOption?: object | null;
|
||||
prepareState?: (state: any) => any;
|
||||
}
|
||||
|
||||
export interface MessageListenerConfig {
|
||||
@ -34,7 +35,9 @@ export function isActionAllowed(config: Config): (type: string) => boolean;
|
||||
export function createMessageListener(config: MessageListenerConfig): void;
|
||||
export function createStateSyncMiddleware(config?: Config): Middleware;
|
||||
export function withReduxStateSync(
|
||||
appReducer: Reducer
|
||||
appReducer: Reducer,
|
||||
prepareInitialStateForStore?: (state: any) => any,
|
||||
): (state: any, action: AnyAction) => Reducer;
|
||||
export function initStateWithPrevTab(store: Store): Store;
|
||||
export function initMessageListener(store: Store): Store;
|
||||
export function isActionSynced(action: AnyAction): boolean;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { createStore, applyMiddleware, Action } from "redux";
|
||||
import { createStateSyncMiddleware, initStateWithPrevTab, withReduxStateSync } from "redux-state-sync";
|
||||
import { createStateSyncMiddleware, initStateWithPrevTab, withReduxStateSync, initMessageListener } from "redux-state-sync";
|
||||
|
||||
interface TestState {
|
||||
a: number;
|
||||
@ -7,16 +7,18 @@ interface TestState {
|
||||
c: string;
|
||||
}
|
||||
const middleware = createStateSyncMiddleware({
|
||||
channel: 'test',
|
||||
predicate: (action) => true,
|
||||
blacklist: [],
|
||||
whitelist: [],
|
||||
broadcastChannelOption: {}
|
||||
});
|
||||
channel: 'test',
|
||||
predicate: (action) => true,
|
||||
blacklist: [],
|
||||
whitelist: [],
|
||||
broadcastChannelOption: {},
|
||||
prepareState: (state) => state,
|
||||
});
|
||||
|
||||
function rootReducer(state: TestState, action: Action): TestState {
|
||||
return state;
|
||||
}
|
||||
|
||||
const store = createStore(withReduxStateSync(rootReducer), ['test'], applyMiddleware(middleware));
|
||||
const store = createStore(withReduxStateSync(rootReducer, (state) => state), ['test'], applyMiddleware(middleware));
|
||||
initStateWithPrevTab(store);
|
||||
initMessageListener(store);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user