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