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

TypeScript redux-observable.combineEpics函数代码示例

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

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



在下文中一共展示了combineEpics函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: combineEpics

export const pricingServiceEpic = (pricingService$, openFin, referenceDataService) => {
  const stalePriceEpic = action$ => {
    // For each symbol
    return getSymbol$(action$)
    // creates a new price stream and will wait to debounce
      .mergeMap(symbol => pricingService$.getSpotPriceStream({symbol}).debounceTime(MS_FOR_LAST_PRICE_TO_BECOME_STALE))
      // when debounces, it creates an action
      .map(createStalePriceAction)
  }

  const publishPriceToOpenFinEpic = action$ => {
    return priceForReferenceServiceSymbols$(action$, pricingService$)
      .map(addRatePrecisionToPrice(referenceDataService))
      .do(publishPriceToOpenFin(openFin))
      // Hack to never emit any actions, because we don't need any action.
      .takeLast()
  }

  const updatePricesEpic = action$ => {
    return priceForReferenceServiceSymbols$(action$, pricingService$)
      .scan(reducePrices, {})
      .map(createSpotPricesUpdateAction)
  }

  const pricingServiceStatusEpic = action$ => {
    return action$.ofType(REF_ACTION_TYPES.REFERENCE_SERVICE)
    // when previous action happens, starts listening on the service status
      .flatMapTo(pricingService$.serviceStatusStream)
      // creates action if service status changes
      .map(createPricingServiceStatusUpdateAction)
  }

  return combineEpics(updatePricesEpic, stalePriceEpic, pricingServiceStatusEpic, publishPriceToOpenFinEpic)
}
开发者ID:carlosrfernandez,项目名称:ReactiveTraderCloud,代码行数:34,代码来源:pricingActions.ts


示例2: reduxCreateStore

export const createStore = () =>
    reduxCreateStore(
        combineReducers<ChatState>({
            adaptiveCards,
            connection,
            format,
            history,
            shell,
            size
        }),
        applyMiddleware(createEpicMiddleware(combineEpics(
            updateSelectedActivityEpic,
            sendMessageEpic,
            trySendMessageEpic,
            retrySendMessageEpic,
            showTypingEpic,
            sendTypingEpic,
            speakSSMLEpic,
            speakOnMessageReceivedEpic,
            startListeningEpic,
            stopListeningEpic,
            stopSpeakingEpic,
            listeningSilenceTimeoutEpic
        )))
    );
开发者ID:alfumit,项目名称:BotFramework-WebChat,代码行数:25,代码来源:Store.ts


示例3: constructor

  constructor(
    private devTools: DevToolsExtension,
    private ngRedux: NgRedux<IAppState>,
    private ngReduxRouter: NgReduxRouter,
    private actions: SessionActions,
    private sessionEpics: SessionEpics,
    private listEpics: ListEpics) {

    const enh = (__DEV__ && devTools.isEnabled()) ?
      [ ... enhancers, devTools.enhancer({
        deserializeState: reimmutify,
      }) ] :
      enhancers;

// I don't know how to get this to work so I put a call to it in the action. 
// That is more explicit, I think too which I've heard recommended.
//    middleware.push(createEpicMiddleware(this.listEpics.saveAll));
    middleware.push(createEpicMiddleware(
                      combineEpics(this.sessionEpics.login, 
                                    this.listEpics.saveAll
                                   )
                                   ));

    ngRedux.configureStore(rootReducer, {}, middleware, enhancers);
    ngReduxRouter.initialize();
  }
开发者ID:dancancro,项目名称:rangle-started,代码行数:26,代码来源:app.ts


示例4: stalePriceCheck

export const pricingServiceEpic = (pricingService$) => {

  const pricingStream$ = action$ => action$.ofType(REF_ACTION_TYPES.REFERENCE_SERVICE)
    .map(action => action.payload.currencyPairUpdates.map(currency => currency.currencyPair.symbol))

  function stalePriceCheck(action$) {
    return pricingStream$(action$)
      .mergeMap((symbols: Array<string>) => {
        return Observable.from(symbols)
          .mergeMap(symbol => pricingService$.getSpotPriceStream({ symbol })
            .debounce(() => Observable.interval(PRICE_STALE_AFTER_X_IN_MS))
            .map(stalePricing))
      })
  }

  function getPrices(action$) {
    return pricingStream$(action$)
      .mergeMap((symbols: Array<string>) => getCurrencyPairs(symbols, pricingService$))
      .scan(accumulatePrices, {}).map(fetchPricing)
  }

  function subscribeToConnectionStatus(action$) {
    return pricingStream$(action$)
      .flatMap(item => pricingService$.serviceStatusStream)
      .map(pricingStatusUpdate)
  }

  return combineEpics(getPrices, stalePriceCheck, subscribeToConnectionStatus)
}
开发者ID:tdeheurles,项目名称:ReactiveTraderCloud,代码行数:29,代码来源:pricingOperations.ts


示例5: combineEpics

export const createRootEpic = <State>() =>
  combineEpics(
    createTimelineEpic<State>(),
    createTimelineFavoriteEpic<State>(),
    createTimelineNoteEpic<State>(),
    createTimelinePinnedEventEpic<State>()
  );
开发者ID:,项目名称:,代码行数:7,代码来源:


示例6: createEpicMiddleware

const epicMiddleware = (referenceDataService, blotterService, pricingService, analyticsService, compositeStatusService, executionService, openFin) => createEpicMiddleware(
  combineEpics(
    referenceServiceEpic(referenceDataService),
    blotterServiceEpic(blotterService),
    pricingServiceEpic(pricingService),
    analyticsServiceEpic(analyticsService),
    compositeStatusServiceEpic(compositeStatusService),
    connectionStatusEpicsCreator(compositeStatusService),
    spotTileEpicsCreator(executionService, pricingService, referenceDataService),
    popoutEpic(),
    footerEpic(openFin),
  ),
)
开发者ID:tdeheurles,项目名称:ReactiveTraderCloud,代码行数:13,代码来源:configureStore.ts


示例7: configureStore

export default function configureStore(initialState: Partial<AppState>) {
  const rootEpic = combineEpics<Epic>(...coreEpics.allEpics);
  const epicMiddleware = createEpicMiddleware();
  const middlewares = [epicMiddleware, coreMiddlewares.errorMiddleware];

  const store = createStore(
    rootReducer,
    // TODO: Properly type redux store for jupyter-extension
    (initialState as unknown) as any,
    composeEnhancers(applyMiddleware(...middlewares))
  );

  epicMiddleware.run(rootEpic);

  return store;
}
开发者ID:nteract,项目名称:nteract,代码行数:16,代码来源:store.ts


示例8: connectionStatusEpicsCreator

export function connectionStatusEpicsCreator(compositeStatusService$) {
  const connectToServices = () => compositeStatusService$.connection.connect()

  const updateConnectionStateEpic = () => {
    return compositeStatusService$.connectionStatusStream
      .map(connectionStatusToState(compositeStatusService$))
      .map(createConnectionStatusUpdateAction)
  }

  const reconnectEpic = (action$) => {
    return action$.ofType(ACTION_TYPES.RECONNECT)
      .do(connectToServices)
      // Hack to never emit any actions, because we don't need any action.
      .takeLast()
  }

  return combineEpics(updateConnectionStateEpic, reconnectEpic)
}
开发者ID:carlosrfernandez,项目名称:ReactiveTraderCloud,代码行数:18,代码来源:connectionStatusOperations.ts


示例9: spotTileEpicsCreator

export function spotTileEpicsCreator(executionService$, pricingService$, referenceDataService$) {
  function executeTradeEpic(action$) {
    return action$.ofType(ACTION_TYPES.EXECUTE_TRADE)
      .flatMap((action) => {
        return executionService$.executeTrade(action.payload)
      })
      .map(tradeExecuted)
  }

  function onPriceUpdateEpic(action$) {
    return action$.ofType(PRICING_ACTION_TYPES.PRICING_SERVICE)
      .map((payload) => {
        _.values(payload.payload).forEach((item: SpotPrice) => {
          // TODO: do it better
          item.currencyPair = item.currencyPair || referenceDataService$.getCurrencyPair(item.symbol)
        })
        return payload
      })
      .map(action => action.payload)
      .map(updateTiles)
  }

  function displayCurrencyChart(action$) {
    return action$.ofType(ACTION_TYPES.DISPLAY_CURRENCY_CHART)
      .flatMap((payload) => {
        return Observable.fromPromise(payload.payload.openFin.displayCurrencyChart(payload.payload.symbol))
      })
      .map((symbol) => {
        return currencyChartOpened(symbol)
      })
  }

  function onTradeExecuted(action$) {
    return action$.ofType(ACTION_TYPES.TRADE_EXECUTED)
      .delay(DISMISS_NOTIFICATION_AFTER_X_IN_MS)
      .map(action => ({ symbol: action.payload.trade.CurrencyPair || action.payload.trade.currencyPair.symbol }))
      .map(dismissNotification)
  }

  return combineEpics(executeTradeEpic, onPriceUpdateEpic, displayCurrencyChart, onTradeExecuted)
}
开发者ID:tdeheurles,项目名称:ReactiveTraderCloud,代码行数:41,代码来源:spotTileOperations.ts


示例10: connectionStatusEpicsCreator

export function connectionStatusEpicsCreator(compositeStatusService$) {

  function connectionStatusEpic(action$) {
    return compositeStatusService$.connectionStatusStream
      .map((connectionStatus) => {
        return {
          connection: connectionStatus || '',
          connectionType: compositeStatusService$.connectionType || '',
          url: compositeStatusService$.connectionUrl || '',
        }
      })
      .map(fetchConnectionStatus)
  }

  function reconnectEpic(action$) {
    return action$.ofType(ACTION_TYPES.RECONNECT)
      .flatMap((action$) => {
        compositeStatusService$.connection.connect()
        return fetchConnectionStatus
      })
  }

  return combineEpics(connectionStatusEpic, reconnectEpic)
}
开发者ID:tdeheurles,项目名称:ReactiveTraderCloud,代码行数:24,代码来源:connectionStatusOperations.ts


示例11: combineEpics

import { combineEpics } from 'redux-observable';
import { getQuestionsEpic, updateQuestion, getTemplateQuestionsEpic, updateTemplateQuestionsEpic, getApplicationTemplateEpic, saveApplication, replyToApplication, deleteApplication } from './application';
import { getBlogPosts, deleteBlogPost } from './blog';

export const appEpic = combineEpics(
  getQuestionsEpic,
  updateQuestion,
  getTemplateQuestionsEpic,
  updateTemplateQuestionsEpic,
  getApplicationTemplateEpic,
  saveApplication,
  deleteApplication,
  replyToApplication,
  getBlogPosts,
  deleteBlogPost,
);
开发者ID:WhateverSkynet,项目名称:nodebb-plugin-moonlight,代码行数:16,代码来源:index.ts


示例12: combineEpics

export const createLogEntriesEpic = <State>() =>
  combineEpics(
    createEntriesEffectsEpic<State>(),
    loadEntriesEpic as EpicWithState<typeof loadEntriesEpic, State>,
    loadMoreEntriesEpic as EpicWithState<typeof loadEntriesEpic, State>
  );
开发者ID:salihkardan,项目名称:kibana,代码行数:6,代码来源:epic.ts


示例13: ofType

  );

const fetchAllReposEpic = (action$, store) =>
  action$.pipe(
    ofType(FETCH_ALL_REPOS),
    flatMap(({ username, startPage }) => {
      const userTotalRepos = store.value.user.get("starred");
      const totalPages = Math.ceil(userTotalRepos / 30) + 1;

      return forkJoin(
        ...Range(startPage, totalPages)
          .map(page =>
            get({
              endpoint: `users/${username}/starred`,
              params: { page }
            })
          )
          .toArray()
      ).pipe(
        map(repos => AddRepos(List(repos).flatten(1))),
        catchError(err => of(setError(err), stopLoading()))
      );
    })
  );

export default combineEpics(
  fetchReposEpic,
  fetchTotalReposLengthEpic,
  fetchAllReposEpic
);
开发者ID:alex3165,项目名称:github-issues,代码行数:30,代码来源:repositories.ts


示例14: cuid

import { combineEpics, Epic } from 'redux-observable';
import { isActionOf } from 'typesafe-actions';
import { Observable } from 'rxjs/Observable';
import cuid from 'cuid';

import { RootAction, RootState } from '@src/redux';
import { todosActions } from '@src/redux/todos';
import { toastsActions } from './';

const TOAST_LIFETIME = 2000;

const addTodoToast: Epic<RootAction, RootState> =
  (action$, store) => action$
    .filter(isActionOf(todosActions.addTodo))
    .concatMap((action) => { // action is type: { type: "ADD_TODO"; payload: string; }
      const toast = { id: cuid(), text: action.payload.title };

      const addToast$ = Observable.of(toastsActions.addToast(toast));
      const removeToast$ = Observable.of(toastsActions.removeToast(toast.id))
        .delay(TOAST_LIFETIME);

      return addToast$.concat(removeToast$);
    });

export const epics = combineEpics(addTodoToast);
开发者ID:vin1992,项目名称:react-redux-typescript-guide,代码行数:25,代码来源:epics.ts


示例15: ofType

  action$.pipe(
    ofType(FETCH_GITHUB_TOKEN),
    mergeMap(({ code }) =>
      get({
        fullEndpoint: "https://api.giistr.com/github-login",
        params: { code }
      })
    ),
    map((res: any) => oauthUser(res.get("access_token")))
  );

const oauthUserEpic = action$ =>
  action$.pipe(
    ofType(OAUTH_USER),
    concatMap(({ token }) =>
      get({
        endpoint: "user",
        params: { access_token: token }
      }).pipe(map(user => addUser(user.set("access_token", token))))
    )
  );

const fetchUserEpic = action$ =>
  action$.pipe(
    ofType(FETCH_USER),
    mergeMap(({ username }) => get({ endpoint: `users/${username}` })),
    map(addUser)
  );

export default combineEpics(fetchTokenEpic, oauthUserEpic, fetchUserEpic);
开发者ID:alex3165,项目名称:github-issues,代码行数:30,代码来源:user.ts


示例16: combineEpics

import { middlewares as coreMiddlewares, reducers } from "@nteract/core";
import { applyMiddleware, combineReducers, createStore, Store } from "redux";
import { combineEpics, createEpicMiddleware } from "redux-observable";

import { Actions } from "./actions";
import epics from "./epics";
import { handleDesktopNotebook } from "./reducers";
import { DesktopNotebookAppState } from "./state";

const rootEpic = combineEpics(...epics);
const epicMiddleware = createEpicMiddleware<
  Actions,
  Actions,
  DesktopNotebookAppState,
  any
>();
const middlewares = [epicMiddleware, coreMiddlewares.errorMiddleware];

export type DesktopStore = Store<DesktopNotebookAppState, Actions>;

if (process.env.DEBUG === "true") {
  middlewares.push(coreMiddlewares.logger());
}

const rootReducer = combineReducers({
  app: reducers.app,
  comms: reducers.comms,
  config: reducers.config,
  core: reducers.core,
  desktopNotebook: handleDesktopNotebook
});
开发者ID:nteract,项目名称:nteract,代码行数:31,代码来源:store.ts


示例17: spotTileEpicsCreator

export function spotTileEpicsCreator(executionService$, referenceDataService, openfin) {
  function executeTradeEpic(action$) {
    return action$.ofType(SPOT_TILE_ACTION_TYPES.EXECUTE_TRADE)
      .flatMap((action) => executionService$.executeTrade(action.payload), (request, result) => ({ request, result }))
      .map(x => tradeExecuted(x.result, x.request.meta))
  }

  function onPriceUpdateEpic(action$) {
    return action$.ofType(PRICING_ACTION_TYPES.SPOT_PRICES_UPDATE)
      .map(extractPayload)
      .map(addCurrencyPairToSpotPrices(referenceDataService))
      .map(updateTiles)
  }

  function displayCurrencyChart(action$) {
    return action$.ofType(SPOT_TILE_ACTION_TYPES.DISPLAY_CURRENCY_CHART)
      .flatMap((payload) => {
        return Observable.fromPromise(payload.payload.openFin.displayCurrencyChart(payload.payload.symbol))
      })
      .map((symbol) => {
        return currencyChartOpened(symbol)
      })
  }

  function onTradeExecuted(action$) {
    return action$.ofType(SPOT_TILE_ACTION_TYPES.TRADE_EXECUTED)
      .do(action => {
        openfin.isRunningInOpenFin && action.meta && openfin.sendPositionClosedNotification(action.meta.uuid, action.meta.correlationId)
      })
      .delay(DISMISS_NOTIFICATION_AFTER_X_IN_MS)
      .map(action => ({ symbol: action.payload.trade.CurrencyPair || action.payload.trade.symbol }))
      .map(dismissNotification)
  }

  function createTrade(msg, price) {
    const direction = msg.amount > 0 ? Direction.Sell : Direction.Buy
    const notional = Math.abs(msg.amount)

    const spotRate = direction === Direction.Buy
      ? price.ask
      : price.bid

    return {
      CurrencyPair: price.symbol,
      SpotRate: spotRate,
      Direction: direction,
      Notional: notional,
      DealtCurrency: price.currencyPair.base,
    }
  }

  function closePositionEpic(action$, store) {
    return action$.ofType(REF_ACTION_TYPES.REFERENCE_SERVICE)
      .do(() => {
        openfin.addSubscription('close-position', (msg, uuid) => {
          const trade = createTrade(msg, store.getState().pricingService[msg.symbol])
          store.dispatch(executeTrade(trade, { uuid, correlationId: msg.correlationId }))
        })
      })
      .filter(() => false)
  }

  return combineEpics(executeTradeEpic, onPriceUpdateEpic, displayCurrencyChart, onTradeExecuted, closePositionEpic)
}
开发者ID:carlosrfernandez,项目名称:ReactiveTraderCloud,代码行数:64,代码来源:epics.ts


示例18: default

export default (action$, store) =>
  combineEpics(...epics)(action$, store)
  .do({error: err => {
    console.error(err);
  }});
开发者ID:dtysky,项目名称:MoeNotes,代码行数:5,代码来源:index.ts


示例19: combineEpics

export const createRootEpic = () => combineEpics(pingEpic);
开发者ID:KTruong888,项目名称:resources,代码行数:1,代码来源:store.utils.ts


示例20: combineEpics

export const createLogSummaryEpic = <State>() =>
  combineEpics(createSummaryEffectsEpic<State>(), loadSummaryEpic as EpicWithState<
    typeof loadSummaryEpic,
    State
  >);
开发者ID:gingerwizard,项目名称:kibana,代码行数:5,代码来源:epic.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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