當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript redux.Unsubscribe類代碼示例

本文整理匯總了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);
開發者ID:KevLeong,項目名稱:redux,代碼行數:30,代碼來源:store.ts

示例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();
    });
  });
}
開發者ID:w1cked,項目名稱:DIM,代碼行數:26,代碼來源:settings.ts


注:本文中的redux.Unsubscribe類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。