Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Last active January 18, 2020 04:40
Show Gist options
  • Save alexytiger/fccb55db42c60c25e9d31826d95e6463 to your computer and use it in GitHub Desktop.
Save alexytiger/fccb55db42c60c25e9d31826d95e6463 to your computer and use it in GitHub Desktop.
uploadImage$ = createEffect(
() =>
this.actions$.pipe(
ofType(IpfsImageActions.uploadImage),
map(action => action.file),
exhaustMap((file) => {
return this.ipfsSrv.addFile(file).pipe(
tap(ipfsHash => console.log(`IPFS file hash: ${ipfsHash}`)),
map(ipfsHash => IpfsImageActions.uploadImageSuccess({ ipfsHash })),
catchError((err: Error) =>
of(this.handleError(err), IpfsImageActions.uploadImageFail())
)
);
})
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment