Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Created June 7, 2019 17:57
Show Gist options
  • Save alexytiger/c725e93e577ab17c87503247fd59029c to your computer and use it in GitHub Desktop.
Save alexytiger/c725e93e577ab17c87503247fd59029c to your computer and use it in GitHub Desktop.
loadFile$ = createEffect(
() =>
this.actions$.pipe(
ofType(IpfsUploadActions.load_image),
withLatestFrom(this.store$.pipe(select(fromStore.getIpfsHash))),
map(([action, ipfsHash]) => ipfsHash),
exhaustMap((ipfsHash: string) =>
this.ipfsSrv.getFile(ipfsHash).pipe(
map((image: Blob) => IpfsUploadActions.load_image_success({ image })),
catchError((err: Error) =>
of(ErrorActions.errorMessage({ errorMsg: err.message }))
)
)
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment