Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(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)))
})
(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)))
})
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)))
})
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)))
})
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 }));
}
},
};
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)))
)
)
);
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]),
),
),
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() })))
)
)
);
const loadAllUrlsEpic: Epic = actions =>
actions.pipe(
filter(isActionOf(loadAllUrls)),
mergeMap(action => action.payload.resources.map(url => doAnalysis.request({ resource: url }))),
);
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;
}
},
};