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