• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript redux.MiddlewareAPI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中redux.MiddlewareAPI的典型用法代码示例。如果您正苦于以下问题:TypeScript MiddlewareAPI类的具体用法?TypeScript MiddlewareAPI怎么用?TypeScript MiddlewareAPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MiddlewareAPI类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 backendMiddleware: Middleware = <AppState>(store: MiddlewareAPI<AppState>) => (next: Dispatch<AppState>) => (originalAction: any) => {
    const result = next(originalAction);
    const action: AppAction = originalAction as any;

    ipcRenderer.send('action', [store.getState(), action]);

    return result
}
开发者ID:istvan-antal,项目名称:copycat,代码行数:8,代码来源:store.ts


示例4: fetchLatestVersions

    function fetchLatestVersions(store: MiddlewareAPI<AppState>): void
    {
        const state = store.getState();

        state.installedApps.apps
            .filter(_ => _.latestVersion === null)
            .forEach(app => store.dispatch(requestLatestVersion(app.id)));
    }
开发者ID:foxable,项目名称:app-manager,代码行数:8,代码来源:fetchRegisteredApps.ts


示例5: 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


示例6: next

 return (next: Dispatch) => (action: Action) => {
   const prevState = store.getState()
   const res = next(action)
   const newState = store.getState()
   if (prevState.currentGame !== newState.currentGame) {
     console.log('[Redux auto save middleware] Current game state changed. Triggering save game action.')
     return next(saveGameAction(newState.currentGame))
   }
   return res
 }
开发者ID:Holi0317,项目名称:bridge-calc,代码行数:10,代码来源:auto-save.ts


示例7: next

 <A extends Action>(action: A) => {
   console.log('will dispatch', action);
   const returnValue = next(action);
   console.log('state after dispatch', api.getState());
   return returnValue;
 };
开发者ID:kanecop,项目名称:react_laravel,代码行数:6,代码来源:logger.ts


示例8: next

) => (action: any) => {
  console.log("dispatching", action);
  let result = next(action);
  console.log("next state", store.getState());
  return result;
};
开发者ID:vvscode,项目名称:code-notes,代码行数:6,代码来源:logger.ts


示例9:

 ) => next => action => {
   api.dispatch({ type: 'INCREMENT' })
   api.dispatch({ type: 'DECREMENT' })
   // typings:expect-error
   api.dispatch({ type: 'UNKNOWN' })
 }
开发者ID:Evan726,项目名称:redux,代码行数:6,代码来源:middleware.ts


示例10:

 .then(systemApps => store.dispatch(receiveSystemApps(systemApps)));
开发者ID:foxable,项目名称:app-manager,代码行数:1,代码来源:fetchSystemApps.ts



注:本文中的redux.MiddlewareAPI类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript redux.Reducer类代码示例发布时间:2022-05-25
下一篇:
TypeScript redux.IDispatch类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap