How to use the typesafe-actions.isActionOf function in typesafe-actions

To help you get started, we’ve selected a few typesafe-actions 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 hectim / parcel-react-app / src / dog / epics.ts View on Github external
(action$, store) => action$
    .filter(isActionOf(DogActions.dogRequest))
    .debounceTime(400)
    .flatMap(() => {
      return Observable
        .ajax({crossDomain: true, method: 'GET', url: 'https://dog.ceo/api/breeds/image/random'})
        // delay to allow cancellation
        .delay(2000)
        .takeUntil(action$.filter(isActionOf(DogActions.dogCancel)))
        .map(res => res.response.message)
        .map(imgSrc => DogActions.dogSuccess(imgSrc))
        .catch(error => Observable.of(DogActions.dogFailure(error)))
    })
github hectim / parcel-react-app / src / observable.ts View on Github external
(action$, store) => action$
    .filter(isActionOf(generalActions.request))
    .debounceTime(200)
    .flatMap(() => {
      return Observable
        .ajax({crossDomain: true, method: 'GET', url: 'https://dog.ceo/api/breeds/image/random'})
        .map(res => {
          console.log('~~~~~ in apicall', res);
          return res.response.message;
        })
        .map(dog => generalActions.success(dog))
        .catch(error => Observable.of(generalActions.failure(error)))
    })
github hectim / parcel-react-app / src / graph / epics / labels.ts View on Github external
const updateLabelEpic: Epic = (action$, store) => action$
  .filter(isActionOf(GraphActions.updateLabelRequest))
  .do((test) => { console.log('update label epic', test) })
  .flatMap((action) => {
    return Observable
      .ajax({crossDomain: true, method: 'GET', url: 'https://dog.ceo/api/breeds/image/random'})
      .map(res => ({ img: res.response.message, nodeId: 1, prevImg: action.payload.img}) as UpdateLabel)
      .map(myLabel => GraphActions.updateLabelSuccess(myLabel))
      .catch(error => Observable.of(GraphActions.updateLabelFailure(error)))
  })
github hectim / parcel-react-app / src / graph / epics / labels.ts View on Github external
const createLabelEpic: Epic = (action$, store) => action$
  .filter(isActionOf(GraphActions.createLabelRequest))
  .do(() => { console.log('create label epic', action$) })
  .flatMap(() => {
    return Observable
      .ajax({crossDomain: true, method: 'GET', url: 'https://dog.ceo/api/breeds/image/random'})
      .map(res => ({ img: res.response.message, nodeId: 1 }) as Label)
      .do(test => { console.log('lol', test) })
      .map(myLabel => GraphActions.createLabelSuccess(myLabel))
      .catch(error => Observable.of(GraphActions.createLabelFailure(error)))
  })
github FreemapSlovakia / freemap-v3-react / src / processors / routePlannerRefocusMapProcessor.ts View on Github external
handle: async ({ dispatch, getState, action }) => {
    const {
      routePlanner: { start, finish },
    } = getState();

    let focusPoint: LatLon | null | undefined;
    if (isActionOf(routePlannerSetStart, action)) {
      focusPoint = start;
    } else if (isActionOf(routePlannerSetFinish, action)) {
      focusPoint = finish;
    }

    const le = getMapLeafletElement();

    if (
      focusPoint &&
      le &&
      !le.getBounds().contains({ lat: focusPoint.lat, lng: focusPoint.lon })
    ) {
      dispatch(mapRefocus({ lat: focusPoint.lat, lon: focusPoint.lon }));
    }
  },
};
github piotrwitek / react-redux-typescript-realworld-app / src / features / articles / epics.ts View on Github external
export const updateArticlesEpic: RootEpic = (action$, state$, { api }) =>
  action$.pipe(
    filter(isActionOf(updateArticleAsync.request)),
    switchMap(action =>
      from(api.articles.updateArticle(action.payload)).pipe(
        map(updateArticleAsync.success),
        catchError(message => of(updateArticleAsync.failure(message)))
      )
    )
  );
github FreemapSlovakia / freemap-v3-react / src / processors / routePlannerToggleElevationChartProcessor.ts View on Github external
handle: async ({ dispatch, getState, action }) => {
    const shown = !!getState().elevationChart.trackGeojson;
    const toggling = isActionOf(routePlannerToggleElevationChart, action);
    if (toggling && shown) {
      dispatch(elevationChartClose());
    } else if ((!shown && toggling) || (shown && !toggling)) {
      const { alternatives, activeAlternativeIndex } = getState().routePlanner;
      dispatch(
        elevationChartSetTrackGeojson(
          lineString(
            ([] as any[])
              .concat(
                ...alternatives[activeAlternativeIndex].itinerary.map(
                  ({ shapePoints }) => shapePoints,
                ),
              )
              .map(([lat, lon]) => [lon, lat]),
          ),
        ),
github digirati-labs / hyperion / packages / vault / src / redux / requestEpic.ts View on Github external
const requestEpic: Epic = (
  action$,
  store,
  { fetch }
) =>
  action$.pipe(
    filter(isActionOf(requestResource)),
    mergeMap(({ payload }) =>
      fetch(payload.id).pipe(
        mergeMap(actionListFromResource(payload.id)),
        catchError(error => of(requestError({ id: payload.id, message: error.toString() })))
      )
    )
  );
github mixer / webpack-bundle-compare / src / client / redux / epics.ts View on Github external
const loadAllUrlsEpic: Epic = actions =>
  actions.pipe(
    filter(isActionOf(loadAllUrls)),
    mergeMap(action => action.payload.resources.map(url => doAnalysis.request({ resource: url }))),
  );
github FreemapSlovakia / freemap-v3-react / src / processors / urlProcessor.ts View on Github external
if (label) {
        parts.push(`l:${encodeURIComponent(label.replace(/\//g, '_'))}`);
      }
      queryParts.push(parts.join('/'));
    }

    if (tracking.activeTrackId) {
      queryParts.push(`follow=${encodeURIComponent(tracking.activeTrackId)}`);
    }

    const search = `?${queryParts.join('&')}`;

    if (window.location.search !== search) {
      const method =
        lastActionType &&
        isActionOf([mapRefocus, distanceMeasurementUpdatePoint], action)
          ? 'replace'
          : 'push';
      history[method]({ pathname: '/', search });
      lastActionType = action.type;
    }
  },
};