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


TypeScript react-redux.Dispatch類代碼示例

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


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

示例1: return

 return (dispatch: Dispatch<AdminUIState>) => {
   dispatch(instructionsBoxCollapsedSetting.set(collapsed));
   dispatch(saveUIData({
     key: INSTRUCTIONS_BOX_COLLAPSED_KEY,
     value: collapsed,
   }));
 };
開發者ID:asubiotto,項目名稱:cockroach,代碼行數:7,代碼來源:alerts.ts

示例2: viewportToTile

   (dispatch : Dispatch<Action>) => {
     const [tx, ty] = viewportToTile(x, y);
     if(tx < 0 || ty < 0 || tx > 128 || ty > 128){
       dispatch(zoomOutOf());
     }else{
       dispatch(zoomInto(tx, ty));
     }
 };
開發者ID:mariusGundersen,項目名稱:Ekkiog,代碼行數:8,代碼來源:emitterRedux.ts

示例3: async

 return async (dispatch: Dispatch<any>)  => {
     dispatch(beginSaveRecipe());
     try {
          const savedRecipe = await save(recipe);
          dispatch(saveRecipeSuccess(savedRecipe));
     } catch (e) {
         dispatch(saveRecipeError(recipe));
     }
 };
開發者ID:SpiderUnicorn,項目名稱:react-redux-typescript,代碼行數:9,代碼來源:index.ts

示例4: return

  return (dispatch: Dispatch<State>, getState: () => State) => {
    dispatch(ActionCreators.GuestAuthStarted.create({}));

    fetch(`${config.apiUrl}TODO`, {
        method: 'POST',
        body: JSON.stringify({token: loginToken}),
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-Type': 'application/json'
        },
      })
    .then(res => res.json())
    .then(data => {
      if (data.userId) {
        dispatch(ActionCreators.GuestAuthSuccess.create({apiToken: data.userId, playlistId: data.playlistId }));
      } else {
        dispatch(ActionCreators.GuestAuthError.create({
          errorMessage: 'Authorization error'
        }));
      }
    })
    .catch((error: Error) => {
      dispatch(ActionCreators.GuestAuthError.create({
        errorMessage: error.message ? error.message : 'Authorization error'
      }));
    });
  };
開發者ID:marcin93w,項目名稱:SpotifyCommon,代碼行數:27,代碼來源:login.ts

示例5: return

 return (dispatch: Dispatch<State>, getState: () => State) => {
   dispatch(ActionCreators.PlaylistFetchStarted.create({}));
   fetch(`${config.apiUrl}playlist/tracks/${getState().user.playlistId}/${getState().user.apiToken}`)
   .then(res => res.json())
   .then(data => {
     dispatch(ActionCreators.PlaylistFetchSuccess.create({playlist: data}));
   })
   .catch((error: Error) => {
     dispatch(ActionCreators.PlaylistFetchError.create({
       errorMessage: error.message ? error.message : 'Error'
     }));
   });
 };
開發者ID:marcin93w,項目名稱:SpotifyCommon,代碼行數:13,代碼來源:playlist.ts

示例6: return

 return (dispatch: Dispatch<State>, getState: () => State) => {
   dispatch(ActionCreators.SearchFetchStarted.create({query}));
   fetch(`${config.apiUrl}search/${getState().user.playlistId}?value=${query}`)
   .then(res => res.json())
   .then(data => {
     dispatch(ActionCreators.SearchFetchSuccess.create({results: data}));
   })
   .catch((error: Error) => {
     dispatch(ActionCreators.SearchFetchError.create({
       errorMessage: error.message ? error.message : 'Error'
     }));
   });
 };
開發者ID:marcin93w,項目名稱:SpotifyCommon,代碼行數:13,代碼來源:search.ts

示例7: getEditionsForVersion

 editionsPerVersion => {
   const editions = getEditionsForVersion(editionsPerVersion, version);
   if (editions) {
     dispatch(setEditions(editions));
   } else {
     dispatch(setEditions(getEditionsForLastVersion(editionsPerVersion), true));
   }
 },
開發者ID:christophelevis,項目名稱:sonarqube,代碼行數:8,代碼來源:actions.ts

示例8: dispatch

 .then(data => {
   if (data.userId) {
     dispatch(ActionCreators.GuestAuthSuccess.create({apiToken: data.userId, playlistId: data.playlistId }));
   } else {
     dispatch(ActionCreators.GuestAuthError.create({
       errorMessage: 'Authorization error'
     }));
   }
 })
開發者ID:marcin93w,項目名稱:SpotifyCommon,代碼行數:9,代碼來源:login.ts

示例9: Error

        }, () => {
            // Unsuccessful, clear all tokens
            dispatch(expire());

            // Close chat and close all other signalr connections
            dispatch(close());
            EventService.getInstance().fire("signalr.stop");

            // Navigate to login
            dispatch(push("/login"));

            throw new Error(__("Your session expired. Please login again."));
        });
開發者ID:cschleiden,項目名稱:imperaplus-client,代碼行數:13,代碼來源:session.service.ts


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