当前位置: 首页>>代码示例>>TypeScript>>正文


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

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


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


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