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