本文整理汇总了TypeScript中redux.Unsubscribe.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Unsubscribe.default方法的具体用法?TypeScript Unsubscribe.default怎么用?TypeScript Unsubscribe.default使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redux.Unsubscribe
的用法示例。
在下文中一共展示了Unsubscribe.default方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: initSettings
export function initSettings() {
if (unsubscribe) {
// Stop saving settings changes
unsubscribe();
}
SyncService.get().then((data) => {
data = data || {};
const savedSettings = (data['settings-v1.0'] || {}) as Partial<Settings>;
$rootScope.$evalAsync(() => {
const languageChanged = savedSettings.language !== i18next.language;
store.dispatch(loaded(savedSettings));
const settings = store.getState().settings;
localStorage.setItem('dimLanguage', settings.language);
if (languageChanged) {
i18next.changeLanguage(settings.language);
}
readyResolve();
// Start saving settings changes
unsubscribe = saveSettingsOnUpdate();
});
});
}
示例2:
}, 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);