本文整理汇总了TypeScript中redux.Unsubscribe类的典型用法代码示例。如果您正苦于以下问题:TypeScript Unsubscribe类的具体用法?TypeScript Unsubscribe怎么用?TypeScript Unsubscribe使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Unsubscribe类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
}, 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);
示例2: 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();
});
});
}