Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Last active May 11, 2019 03:33
Show Gist options
  • Save alexytiger/1c0ac6357662793b9043722adea4f470 to your computer and use it in GitHub Desktop.
Save alexytiger/1c0ac6357662793b9043722adea4f470 to your computer and use it in GitHub Desktop.
@Injectable()
export class IpfsDaemonEffects {
constructor(
private ipfsSrv: IpfsDaemonService,
private readonly actions$: Actions
) {}
onConnectEffect$ = createEffect(
() =>
this.actions$.pipe(
ofType(ROOT_EFFECTS_INIT),
switchMap(() =>
this.ipfsSrv.getVersion().pipe(
tap(version => console.log(`IPFS node version: ${version}`)),
map(_ => IpfsDaemonActions.connectSuccess()),
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