当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Store.dispatch方法代码示例

本文整理汇总了TypeScript中redux.Store.dispatch方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Store.dispatch方法的具体用法?TypeScript Store.dispatch怎么用?TypeScript Store.dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redux.Store的用法示例。


在下文中一共展示了Store.dispatch方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: doCorked

export function doCorked(store: Store<any>, func: () => void) {
    try {
        store.dispatch(actions.cork())
        func()
    } finally {
        store.dispatch(actions.uncork())
    }
}
开发者ID:RX14,项目名称:discord-curses,代码行数:8,代码来源:utils.ts

示例2: 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

示例3: configureStore

const createStore = (currentUser?: T.CurrentUser, appState?: T.AppState) => {
  store = configureStore(rootReducer);
  if (currentUser) {
    store.dispatch(receiveCurrentUser(currentUser));
  }
  if (appState) {
    store.dispatch(setAppState(appState));
  }
  return store;
};
开发者ID:SonarSource,项目名称:sonarqube,代码行数:10,代码来源:getStore.ts

示例4: it

    it('should call the load function with only the series IDs that have requested loads', () => {
      store.dispatch({
        type: ActionType.DATA_REQUESTED,
        payload: [ SERIES_A ]
      });
      store.dispatch(_performDataLoad());

      dataLoaderSpy.calledOnce.should.be.true();
      dataLoaderSpy.firstCall.args[0].should.deepEqual([ SERIES_A ]);
    });
开发者ID:abe732,项目名称:react-layered-chart,代码行数:10,代码来源:actions-test.ts

示例5: switch

      .map(message => {

        // This is a bit of a hack and we're stretching the limits of a faux
        // chat app. Every time there is a new message, we only want to keep the
        // new ones. This is a case where some sort of queue would be a better
        // model
        if (handledMessages.hasOwnProperty(message.id)) {
          return;
        }
        handledMessages[message.id] = true;

        switch (message.thread.id) {
          case tEcho.id:
            // echo back the same message to the user
            store.dispatch(ThreadActions.addMessage(tEcho, {
              author: echo,
              text: message.text
            }));

            break;
          case tRev.id:
            // echo back the message reveresed to the user
            store.dispatch(ThreadActions.addMessage(tRev, {
              author: rev,
              text: message.text.split('').reverse().join('')
            }));

            break;
          case tWait.id:
            let waitTime: number = parseInt(message.text, 10);
            let reply: string;

            if (isNaN(waitTime)) {
              waitTime = 0;
              reply = `I didn\'t understand ${message}. Try sending me a number`;
            } else {
              reply = `I waited ${waitTime} seconds to send you this.`;
            }

            setTimeout(
              () => {
                store.dispatch(ThreadActions.addMessage(tWait, {
                  author: wait,
                  text: reply
                }));
              },
              waitTime * 1000);

            break;
          default:
            break;
        }
      });
开发者ID:borodovisin,项目名称:Books,代码行数:53,代码来源:chat-example-data.ts

示例6: stepForward

  function stepForward() {
    if (!isPlaying()) {
      timeoutId = 0;
      return;
    }

    schedule();

    if (canForward()) {
      store.dispatch(Actions.playForward());
    } else {
      store.dispatch(Actions.togglePlayback());
    }
  }
开发者ID:proof,项目名称:nqueens-react,代码行数:14,代码来源:middleware.ts

示例7: handleClose

  handleClose() {
    console.error('lost ws connection');

    this._store.dispatch({
      type: 'disconnect',
    });
  }
开发者ID:filharvey,项目名称:manygolf,代码行数:7,代码来源:ws.ts

示例8: return

  return (store: Store<FullState>) => {

    const payload = keeps.reduce(
      (action, { key, storage, load }) => ({ ...action, [key]: load(key, storage), }),
      {}
    );

    store.dispatch({
      payload,
      type: HYDRATE
    });

    const results: { [key: string]: any; } = {};
    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,代码行数:26,代码来源:index.ts

示例9: it

    it('should handle normal actions by default', () => {
      store.dispatch({ type: 'HOLD' });

      expect(store.getState()).to.deep.equal({
        actions: ['HOLD']
      });
    });
开发者ID:valtech-nyc,项目名称:brookjs,代码行数:7,代码来源:eddy.spec.ts


注:本文中的redux.Store.dispatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。