本文整理匯總了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);