當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。