mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* [redux-immutable] Move the current version to v3 subfolder * [redux-immutable] Copied v3 over to root and update it to v4
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
|
|
import { combineReducers } from 'redux-immutable';
|
|
import { Map, List } from 'immutable';
|
|
import { AnyAction } from 'redux';
|
|
|
|
// Dummy State interface
|
|
interface State { };
|
|
|
|
/**
|
|
* Combine reducers should work with only one argument (a reducers object).
|
|
*/
|
|
combineReducers({});
|
|
combineReducers<State>({});
|
|
|
|
/**
|
|
* Combine reducers support reducer with custom action
|
|
*/
|
|
combineReducers<State, { type: string; payload: number | string}>({
|
|
reducerNumber: (state: number, action: { type: string; payload: number }) => {
|
|
switch(action.type) {
|
|
case 'multiply': return state * action.payload
|
|
default: return state
|
|
}
|
|
},
|
|
reducerString: (state: string, action: { type: string; payload: string }) => {
|
|
switch(action.type) {
|
|
case 'concat': return state.concat(action.payload)
|
|
default: return state
|
|
}
|
|
},
|
|
});
|
|
|
|
/**
|
|
* Combine reducers should accepts a function (getDefaultState()) as a second parameter, that returns an immutable Collection.Keyed collection.
|
|
*/
|
|
combineReducers<State, AnyAction, string>({}, () => { return Map<string, State>(); });
|
|
combineReducers<State, AnyAction, number>({}, () => { return Map<number, State>(); });
|
|
/**
|
|
* Combine reducers should accepts a function (getDefaultState()) as a second parameter, that returns an immutable Collection.Indexed collection.
|
|
*/
|
|
combineReducers<State>({}, () => { return List<State>(); });
|