Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Created September 17, 2019 03:36
Show Gist options
  • Save alexytiger/b848cd893bb2a6281a5e586ede168a9b to your computer and use it in GitHub Desktop.
Save alexytiger/b848cd893bb2a6281a5e586ede168a9b to your computer and use it in GitHub Desktop.
downloadImage$ = createEffect(
() =>
this.actions$.pipe(
ofType(IpfsImageActions.download_image),
map((action) => action.ipfsHash),
switchMap((ipfsHash: string) =>
this.ipfsSrv.getFile(ipfsHash).pipe(
map((image: Blob) => IpfsImageActions.download_image_success({ image })),
catchError((err: Error) =>
of(ErrorActions.errorMessage({ errorMsg: err.message }), IpfsImageActions.download_image_error())
)
)
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment