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


TypeScript Dispatch.default方法代碼示例

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


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

示例1: async

export const flushTailBuffer = () => async (
  dispatch: Dispatch<SetTableBackwardDataAction | SetTableForwardDataAction>,
  getState: GetState
) => {
  const {
    logs: {
      tableInfiniteData: {
        forward: currentTailBuffer,
        backward: currentBackward,
      },
    },
  } = getState()

  const combinedBackward = combineTableData(currentTailBuffer, currentBackward)

  await dispatch(setTableBackwardData(combinedBackward))
  await dispatch(setTableForwardData(defaultTableData))
}
開發者ID:viccom,項目名稱:influxdb,代碼行數:18,代碼來源:index.ts

示例2: fetch

export const fetchUsers = () => async (
  dispatch: Dispatch<StoreState>,
  getState: () => StoreState
) => {
  if (Object.keys(getState().users._cache).length > 0) return

  dispatch(setLoading(true))

  dispatch(
    cacheUsers(
      await fetch('http://jsonplaceholder.typicode.com/users').then(response =>
        response.json()
      )
    )
  )

  dispatch(setLoading(false))
}
開發者ID:chaucerbao,項目名稱:react-redux-template,代碼行數:18,代碼來源:users.ts

示例3: getDefinitions

 return getDefinitions(component).then(definitions => {
   const filtered = definitions
     .filter(definition => definition.type !== 'LICENSE')
     // do not display this setting on project level
     .filter(
       definition => !component || definition.key !== 'sonar.branch.longLivedBranches.regex'
     );
   dispatch(receiveDefinitions(filtered));
 });
開發者ID:SonarSource,項目名稱:sonarqube,代碼行數:9,代碼來源:actions.ts

示例4: async

export const addCellAsync = (dashboard: Dashboard) => async (
  dispatch: Dispatch<Action>
): Promise<void> => {
  const cell = getNewDashboardCell(dashboard)

  try {
    const createdCell = await addCellAJAX(dashboard.id, cell)
    const updatedDashboard = {
      ...dashboard,
      cells: [...dashboard.cells, createdCell],
    }

    dispatch(loadDashboard(updatedDashboard))
    dispatch(notify(copy.cellAdded()))
  } catch (error) {
    console.error(error)
  }
}
開發者ID:viccom,項目名稱:influxdb,代碼行數:18,代碼來源:index.ts

示例5: next

    const middleware: Middleware = (store: MiddlewareAPI<AppState>) => (next: Dispatch<AppState>) => (action: AppAction) =>
    {
        switch(action.type)
        {
            case "REQUEST_SYSTEM_APPS": fetchSystemApps(store, action as RequestSystemAppsAction); break;
        }

        return next(action);
    };
開發者ID:foxable,項目名稱:app-manager,代碼行數:9,代碼來源:fetchSystemApps.ts

示例6: return

    return (dispatch:Dispatch<CounterAction>, getState: ()=>ICounterState) => {
        const {counter} = getState();

        if(counter % 2 == 0) {
            return;
        }

        dispatch(increment);
    }
開發者ID:ericlink,項目名稱:ts-angular-redux-seed,代碼行數:9,代碼來源:counter.actions.ts

示例7: async

export const prioritizeItems = (items: MainReportItem[]) => async (dispatch: Dispatch<{}>) => {
  dispatch(onPrioritizeRequest());

  try {

    const data = await exampleClient.prioritizeItems(items);

    if (data) {
      dispatch(onPrioritizeSuccess(data));
    }

  } catch (err) {

    dispatch(onPrioritizeFailure(err));
    return false;
  }
  return true;
};
開發者ID:jmptr,項目名稱:lost-sloth,代碼行數:18,代碼來源:example.ts

示例8: async

 return async (dispatch: Dispatch<IAction<ISiteContent[]>>) => {
     try {
         const siteContent: ISiteContent[] = await api.getLists();
         if (typeof messageData !== "undefined") {
             dispatch(setAllSiteContentAndMessage(siteContent, messageData));
         } else {
             dispatch(setAllSiteContent(siteContent));
         }
     } catch (error) {
         // tslint:disable-next-line:no-console
         console.log(error);
         dispatch(setMessageData({
             message: constants.ERROR_MESSAGE_GET_ALL_SITE_CONTENT,
             showMessage: true,
             type: MessageBarType.error
         }));
     }
 };
開發者ID:DariuS231,項目名稱:ChromeSPPropertiesAdmin,代碼行數:18,代碼來源:spSiteContentActions.ts

示例9: async

 saveAccount: (data: UserClient) => async (
   dispatch: Dispatch<UpdateAction>,
   getState: () => StateTree
 ) => {
   const { api } = getState();
   dispatch({
     type: ActionType.UPDATE,
     state: { isFetchingAccount: true },
   });
   dispatch({
     type: ActionType.UPDATE,
     state: {
       account: await api.saveAccount(data),
       isFetchingAccount: false,
     },
   });
   await actions.claimLocalUser(dispatch, getState);
 },
開發者ID:WordToken,項目名稱:voice-web,代碼行數:18,代碼來源:user.ts

示例10: dispatch

 onDrop: (e: DragEvent, clientRect: ClientRect) => {
   e.preventDefault();
   dispatch(
     Actions.addFigure(
       e.dataTransfer.getData("shape"),
       e.clientX - clientRect.left,
       e.clientY - clientRect.top
     )
   );
 },
開發者ID:vlebedeff,項目名稱:malevich,代碼行數:10,代碼來源:canvas.ts


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