How to use the redux-observable.ofType function in redux-observable

To help you get started, we’ve selected a few redux-observable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EOSIO / eosio-explorer / packages / ui-gui-nodeos / src / pages / ActiondetailPage / components / Actiondetail / ActiondetailReducer.js View on Github external
const fetchEpic = ( action$, state$ ) => action$.pipe(
  ofType(FETCH_START),
  mergeMap(action =>{
    let { value: { actiondetailPage: { actiondetail: { params } }}} = state$;
    
    console.log(params);
    let temp = "?action_digest=" + params.id;
    // return apiMongodb(`get_action_details${paramsToQuery(params)}`).pipe(
    return apiMongodb(`get_action_details${temp}`).pipe(
      map(res => fetchFulfilled(res.response)),
      catchError(error => of(fetchRejected(error.response, { status: error.status })))
    )
  })
);
github SuperblocksHQ / ethereum-studio / src / epics / login / refreshAuth.epic.ts View on Github external
export const refreshAuthStart = (action$: AnyAction, state$: any) => action$.pipe(
    ofType(authActions.REFRESH_AUTH_START),
    withLatestFrom(state$),
    // currently the TTL of AuthToken is 120 sec, so refresh every 110 sec
    map(() => authService.getAuthTokenExpiration()),
    switchMap((authToken: ITokenExpiration) => timer(authToken.nextRefresh * 1000, authToken.refreshInterval * 1000)
        .pipe(
            takeWhile(() => state$.value.auth.isAuthenticated),
            switchMap(() => userService.credentialsExist()
                .pipe(
                    switchMap(() => authService.refreshAuth()
                        .pipe(
                            switchMap((token) => of(authActions.refreshAuthSuccess(token))),
                            catchError((error) => [authActions.refreshAuthFail(error.message)])
                        )
                    )
                )
            )
github SuperblocksHQ / ethereum-studio / src / epics / ipfs / importProjectFromIPFS.epic.js View on Github external
const importProjectFromIPFS = (action$, state$, { router }) => action$.pipe(
    ofType(ipfsActions.IMPORT_PROJECT_FROM_IPFS),
    withLatestFrom(state$),
    switchMap(([action,]) => {
        const hash = action.data;
        return from(ipfsService.ipfsFetchFiles(hash))
        .pipe(
            delayWhen(() => epicUtils.controlAvailable$(router)),
            map(response => response.map(f => convertFile(f))),
            tap(() => router.control.importProject(files, true)),
            map(ipfsActions.importProjectFromIpfsSuccess),
            catchError((error) => {
                console.log("There was an issue importing the project from IPFS: " + error);
                ipfsService.clearTempProject();
                return of(ipfsActions.importProjectFromIpfsFail())
            })
        )
    })
github AdaptiveConsulting / ReactiveTraderCloud / src / client / src / rt-actions / operators.ts View on Github external
import { Action } from 'redux'
import { ofType } from 'redux-observable'
import { ConnectAction, CONNECTION_ACTION_TYPES, DisconnectAction } from './'

export const applicationConnected = ofType(CONNECTION_ACTION_TYPES.CONNECT_SERVICES)
export const applicationDisconnected = ofType(CONNECTION_ACTION_TYPES.DISCONNECT_SERVICES)
github EOSIO / eosio-explorer / src / pages / PushactionPage / PushactionPageReducer.js View on Github external
const recordsUpdateEpic = action$ => action$.pipe(
  ofType(RECORDS_UPDATE),
  mapTo(fetchStart()),
);
github thebrodmann / deox / examples / tasks / src / utils / index.ts View on Github external
export const ofType = <
  I extends AnyAction,
  AC extends ActionCreator,
  O extends AnyAction = AC extends ActionCreator
    ? T extends AnyAction
      ? T
      : never
    : never
>(
  actionCreator: AC
): ((source: Observable<i>) =&gt; Observable) =&gt;
  _ofType(getType(actionCreator)) as any
</i>
github SuperblocksHQ / ethereum-studio / packages / dashboard / src / epics / projects / loadProject.epic.ts View on Github external
export const loadProject: Epic = (action$: any, state$: any) => action$.pipe(
    ofType(projectsActions.LOAD_PROJECT_REQUEST),
    withLatestFrom(state$),
    switchMap(([action, _state]) => {
        const projectId = action.data.projectId;
        return loadProjectById(projectId);
    })
);
github AdaptiveConsulting / ReactiveTraderCloud / src / client / src / openfinEpics.ts View on Github external
const publishPriceToOpenFinEpic: ApplicationEpic = (
  action$,
  store,
  { pricesForCurrenciesInRefData, referenceDataService, openFin }
) =&gt;
  action$.pipe(
    ofType(CONNECT_SERVICES),
    switchMapTo(
      pricesForCurrenciesInRefData.pipe(
        mergeMap(price =&gt;
          referenceDataService.getCurrencyPairUpdates$().pipe(
            map(currencyMap =&gt; addRatePrecisionToPrice(currencyMap, price)),
            tap(enhancedPrice =&gt; openFin.publishPrice(enhancedPrice)),
            filter(() =&gt; false),
            takeUntil(action$.pipe(ofType(DISCONNECT_SERVICES)))
          )
        )
      )
    )
  )
github just4fun / stuhome / src / modules / topic / topicList / topicList.epics.js View on Github external
const fetchTopicList = (action$, state$) => action$.pipe(
  ofType(TOPICLIST_FETCH),
  filter(action => {
    const { boardId, sortType } = action.payload;
    return cacheManager.shouldFetchList(state$.value, 'topicList', boardId, sortType);
  }),
  mergeMap(action =>
    concat(
      of(fetchTopicListRequest(action.payload)),
      fromPromise(api.fetchTopicList(action.payload)).pipe(
        map(({
          data,
          error
        }) => {
          if (!error) {
            return fetchTopicListSuccess(data, action.payload);
          } else {
            return fetchTopicListFailure(error, action.payload);
github msolvaag / redux-db / examples / todo / src / epics.ts View on Github external
export const addComment = (action$: ActionsObservable) =&gt; action$.pipe(
    ofType(actions.ADD_COMMENT),
    switchMap(action =&gt;
        ajax.post(`${API_BASE}/comments`, action.payload, headers).pipe(
            map(e =&gt; mapToDone(action.type, e.response)),
            catchError(e =&gt; Observable.of(({ type: actions.APP_ERROR, payload: e }))))
    ));