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


TypeScript redux.Store類代碼示例

本文整理匯總了TypeScript中redux.Store的典型用法代碼示例。如果您正苦於以下問題:TypeScript Store類的具體用法?TypeScript Store怎麽用?TypeScript Store使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Store類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: compose

const configureStore = (initialState?: State) => {
  const finalCreateStore = compose(applyMiddleware(thunk))(createStore);
  const store: Store<State> = finalCreateStore(rootReducer, initialState);

  if (module.hot) {
    module.hot.accept('./rootReducer', () => {
      const nextRootReducer = require('./rootReducer').default;
      store.replaceReducer(nextRootReducer);
    });
  }

  return store;
};
開發者ID:threehams,項目名稱:reverie-client,代碼行數:13,代碼來源:configureStore.ts

示例2: beforeEach

  beforeEach(() => {
    store = applyMiddleware(ThunkMiddleware)(createStore)(reducer);

    dataLoaderSpy = sinon.spy();

    store.dispatch({
      type: ActionType.SET_DATA_LOADER,
      payload: dataLoaderSpy
    });

    store.dispatch({
      type: ActionType.SET_SERIES_IDS,
      payload: ALL_SERIES
    });

    store.dispatch({
      type: ActionType.DATA_RETURNED,
      payload: {
        [SERIES_A]: [],
        [SERIES_B]: []
      }
    });
  });
開發者ID:abe732,項目名稱:react-layered-chart,代碼行數:23,代碼來源:actions-test.ts

示例3:

store.subscribe(() => {
    let state: State = store.getState();
    let app = document.getElementById("app");
    let innerText = '';
    state.forEach((elem => {
        innerText += `
            <p>${elem}</p>
        `;
    }));
    app.innerHTML = innerText;
});
開發者ID:OlegShatravka,項目名稱:redux-typescript-skeleton,代碼行數:11,代碼來源:main.ts

示例4: generateGetUIDataResponse

      response: () => {
        // This dispatch will trigger the listener, but it shouldn't trigger any
        // other requests.
        store.dispatch({ type: null });

        let body = generateGetUIDataResponse({
          [KEY_REGISTRATION_SYNCHRONIZED]: false,
          [KEY_HELPUS]: {optin: true},
        });
        return { body };
      },
開發者ID:Yogendrovich,項目名稱:cockroach,代碼行數:11,代碼來源:registrationService.spec.ts

示例5: selector

    store.subscribe(() => {
      const state = store.getState();

      for (const { key, selector, storage, save } of keeps) {
        const result = selector(state);

        if (result !== results[key]) {
          results[key] = result;
          save(key, result, storage);
        }
      }
    });
開發者ID:jakelazaroff,項目名稱:redux-keep,代碼行數:12,代碼來源:index.ts

示例6:

 store.subscribe(throttle((): void => {
     const state = store.getState(); // The state is Immutable Map
     if (state.get("isLoading") === true || state.get("valid") === false) {
         return void 0;
     }
     const prevFmtString = (prevState.get("input") || "").split(" ")[0];
     const currFmtString = (state.get("input") || "").split(" ")[0];
     if (
         typeof prevState.get === "function" &&
         state.get("input").length > 0 &&
         state.get("hexData").length > 0 &&
         (
             prevFmtString !== currFmtString ||
             prevState.get("hexData") !== state.get("hexData")
         )
     ) {
         store.dispatch(actions.startLoading());
         const body: APIBody = {
             formatString: state.get("input"),
             input: state.get("hexData"),
         };
         request.post(API_PATH, body)
             .then((res) => {
                 let data = res.data;
                 if (typeof data === "string") {
                     data = JSON.parse(`${data}`);
                 }
                 store.dispatch(actions.updateResults(data.results));
                 store.dispatch(actions.stopLoading());
             })
             .catch((err: AxiosError) => {
                 const errorMsg = (err.response ? err.response.data.error : err.message) ||
                                  err.message ||
                                  "Unknown Error";
                 store.dispatch(actions.stopLoading());
                 store.dispatch(actions.apiError(errorMsg));
             });
     }
     prevState = state;
 }, REQUEST_INTERVAL));
開發者ID:shuntksh,項目名稱:binaryscanr,代碼行數:40,代碼來源:apiRequetHandler.ts

示例7: it

 it("should return false if no data is missing", function () {
   store.dispatch(clusterReducerObj.receiveData(new protos.cockroach.server.serverpb.ClusterResponse({cluster_id: CLUSTER_ID})));
   store.dispatch(setUIDataKey(KEY_HELPUS, {}));
   store.dispatch(setUIDataKey(KEY_REGISTRATION_SYNCHRONIZED, true));
   assert.isFalse(registrationService.shouldLoadKeys(store.getState()));
   assert.isFalse(registrationService.shouldLoadClusterInfo(store.getState()));
   assert.isFalse(registrationService.shouldLoadData(store.getState()));
 });
開發者ID:Yogendrovich,項目名稱:cockroach,代碼行數:8,代碼來源:registrationService.spec.ts

示例8: clearTimeout

 store.subscribe(() => {
   let state = store.getState();
   clearTimeout(timeout);
   if (state.cachedData.cluster.data &&
     state.cachedData.cluster.data.cluster_id &&
     state.uiData[KEY_REGISTRATION_SYNCHRONIZED] &&
     state.uiData[KEY_REGISTRATION_SYNCHRONIZED].data
   ) {
     assert.lengthOf(fetchMock.calls(uiDataFetchURL), 1);
     assert.lengthOf(fetchMock.calls(clusterFetchURL), 1);
     assert.lengthOf(fetchMock.calls(registrationFetchURLPrefix), 0);
     timeout = setTimeout(() => done());
   }
 });
開發者ID:Yogendrovich,項目名稱:cockroach,代碼行數:14,代碼來源:registrationService.spec.ts

示例9: return

    return (action: Action) => {
      let result = next(action);
      if (action.type !== TOGGLE_PLAYBACK) {
        return result;
      }

      if (store.getState().isPlaying) {
        start();
      } else {
        stop();
      }

      return result;
    };
開發者ID:proof,項目名稱:nqueens-react,代碼行數:14,代碼來源:middleware.ts

示例10:

    pendingChannelIds.forEach(async channelId => {
      if (isLocked || !didInit) {
        return
      }

      const paymentChannel = await machinomy.channelById(channelId)

      if (paymentChannel) {
        // Initialize channel with a 0 tip
        await this.initChannel()
        // Remove channelId from watchers
        this.store.dispatch(actions.removePendingChannel(channelId))
      }
    })
開發者ID:8001800,項目名稱:SpankCard,代碼行數:14,代碼來源:MicropaymentsController.ts


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