Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Last active June 7, 2019 01:45
Show Gist options
  • Save alexytiger/5bf33bfbb29be653de9dbafa89fe3da9 to your computer and use it in GitHub Desktop.
Save alexytiger/5bf33bfbb29be653de9dbafa89fe3da9 to your computer and use it in GitHub Desktop.
uploadFile$ = createEffect(
() =>
this.actions$.pipe(
ofType(IpfsUploadActions.upload_image),
map(action => action.file),
exhaustMap((file) => {
return this.ipfsSrv.addFile(file).pipe(
tap(ipfsHash => console.log(`IPFS file hash: ${ipfsHash}`)),
map(ipfsHash => IpfsUploadActions.upload_image_success({ipfsHash})),
catchError((err: Error) =>
of(ErrorActions.errorMessage({ errorMsg: err.message }), IpfsUploadActions.upload_image_fail)
)
)
})
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment