当前位置: 首页>>代码示例>>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;未经允许,请勿转载。