本文整理汇总了TypeScript中redux.Store.replaceReducer方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Store.replaceReducer方法的具体用法?TypeScript Store.replaceReducer怎么用?TypeScript Store.replaceReducer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redux.Store
的用法示例。
在下文中一共展示了Store.replaceReducer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should upgrade new reducers', () => {
const defaultState = {
dispatches: []
};
const reducer = () => defaultState;
store.replaceReducer(reducer);
expect(store.getState()).to.equal(defaultState);
});
示例2: require
module.hot.accept('./rootReducer', () => {
const nextRootReducer = require('./rootReducer').default;
store.replaceReducer(nextRootReducer);
});
示例3: replaceReducer
replaceReducer(nextReducer: Reducer<AppState>): void {
this.store.replaceReducer(nextReducer);
}
示例4: unsubscribe
}, enhancer);
/* dispatch */
store.dispatch({
type: 'ADD_TODO',
text: 'test'
})
/* getState */
const state: State = store.getState();
/* subscribe / unsubscribe */
const unsubscribe: Unsubscribe = store.subscribe(() => {
console.log('Current state:', store.getState())
})
unsubscribe();
/* replaceReducer */
const newReducer: Reducer<State> = reducer;
store.replaceReducer(newReducer);