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


TypeScript MiddlewareAPI.dispatch方法代碼示例

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


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

示例1: next

export const fetchInstalledApps: Middleware = (store: MiddlewareAPI<AppState>) => (next: Dispatch<AppState>) => (action: AppAction) =>
{
    const result = next(action);

    if (action.type === "REQUEST_INSTALLED_APPS")
    {
        store.dispatch(requestRegisteredApps());
        store.dispatch(requestSystemApps());
    }

    return result;
};
開發者ID:foxable,項目名稱:app-manager,代碼行數:12,代碼來源:fetchInstalledApps.ts

示例2: fetchLatestVersion

    async function fetchLatestVersion(store: MiddlewareAPI<AppState>, action: RequestLatestVersionAction): Promise<void>
    {
        const app = store.getState().installedApps.apps.find(_ => _.id === action.payload.appId);

        if (!app) return;

        const versionProvider = appRegistry.loadVersionProvider(app.id);
        const versionProviderAdapter = VersionProviderFactory.create(versionProvider);

        const latestVersion = await versionProviderAdapter.getVersion();        
        const isOutdated = new VersionComparer(app.installedVersion).isLesserThan(latestVersion);

        store.dispatch(receiveLatestVersion(app.id, latestVersion, isOutdated));     
    }
開發者ID:foxable,項目名稱:app-manager,代碼行數:14,代碼來源:fetchRegisteredApps.ts

示例3: next

export const joinRegisteredAppsWithSystemApps: Middleware = (store: MiddlewareAPI<AppState>) => (next: Dispatch<AppState>) => (action: AppAction) =>
{
    const result = next(action);

    if (!(action.type === "RECEIVE_REGISTERED_APPS" || action.type === "RECEIVE_SYSTEM_APPS"))
        return result;

    const state = store.getState();

    if (state.registeredApps.isFetching || state.systemApps.isFetching)
        return result;

    const installedApps = join(state.registeredApps.apps, state.systemApps.apps);

    store.dispatch(receiveInstalledApps(installedApps));

    return result;
};
開發者ID:foxable,項目名稱:app-manager,代碼行數:18,代碼來源:joinRegisteredAppsWithSystemApps.ts

示例4:

 ) => next => action => {
   api.dispatch({ type: 'INCREMENT' })
   api.dispatch({ type: 'DECREMENT' })
   // typings:expect-error
   api.dispatch({ type: 'UNKNOWN' })
 }
開發者ID:Evan726,項目名稱:redux,代碼行數:6,代碼來源:middleware.ts

示例5:

 .then(systemApps => store.dispatch(receiveSystemApps(systemApps)));
開發者ID:foxable,項目名稱:app-manager,代碼行數:1,代碼來源:fetchSystemApps.ts

示例6:

 connection.onAction(action => {
   if (connection.isClient()) action.__$syncAction = true;
   store.dispatch(action);
 });
開發者ID:benjaminjs,項目名稱:redux-nsync,代碼行數:4,代碼來源:index.ts

示例7:

 socket.on('message', (a: SocketAction) => {
     store.dispatch({...a, scope: ActionScope.Local});
 });
開發者ID:Kuchasz,項目名稱:smart-downloader,代碼行數:3,代碼來源:SocketMiddleware.ts

示例8:

 .forEach(app => store.dispatch(requestLatestVersion(app.id)));
開發者ID:foxable,項目名稱:app-manager,代碼行數:1,代碼來源:fetchRegisteredApps.ts

示例9: fetchRegisteredApps

    async function fetchRegisteredApps(store: MiddlewareAPI<AppState>, action: RequestRegisteredAppsAction): Promise<void>
    {
        const registeredApps = await appRegistry.loadApps();

        store.dispatch(receiveRegisteredApps(registeredApps));
    }
開發者ID:foxable,項目名稱:app-manager,代碼行數:6,代碼來源:fetchRegisteredApps.ts


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