Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 })))
)
})
);
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)])
)
)
)
)
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())
})
)
})
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)
const recordsUpdateEpic = action$ => action$.pipe(
ofType(RECORDS_UPDATE),
mapTo(fetchStart()),
);
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>) => Observable) =>
_ofType(getType(actionCreator)) as any
</i>
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);
})
);
const publishPriceToOpenFinEpic: ApplicationEpic = (
action$,
store,
{ pricesForCurrenciesInRefData, referenceDataService, openFin }
) =>
action$.pipe(
ofType(CONNECT_SERVICES),
switchMapTo(
pricesForCurrenciesInRefData.pipe(
mergeMap(price =>
referenceDataService.getCurrencyPairUpdates$().pipe(
map(currencyMap => addRatePrecisionToPrice(currencyMap, price)),
tap(enhancedPrice => openFin.publishPrice(enhancedPrice)),
filter(() => false),
takeUntil(action$.pipe(ofType(DISCONNECT_SERVICES)))
)
)
)
)
)
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);
export const addComment = (action$: ActionsObservable) => action$.pipe(
ofType(actions.ADD_COMMENT),
switchMap(action =>
ajax.post(`${API_BASE}/comments`, action.payload, headers).pipe(
map(e => mapToDone(action.type, e.response)),
catchError(e => Observable.of(({ type: actions.APP_ERROR, payload: e }))))
));