Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Last active September 2, 2019 15:39
Show Gist options
  • Save alexytiger/f2c83acaadaa9b388cd0e43a319f28aa to your computer and use it in GitHub Desktop.
Save alexytiger/f2c83acaadaa9b388cd0e43a319f28aa to your computer and use it in GitHub Desktop.
createProduct$ = createEffect(
() =>
this.actions$.pipe(
ofType(PurchaseContractActions.createPurchaseContract),
map(action => action.payload),
exhaustMap((payload) => {
return this.fleaSrv.createPurchaseContract(payload).pipe(
tap(address => console.log('Contract address: ', address)),
switchMap((address: string) => {
return [
PurchaseContractActions.createPurchaseContractSuccess({
product: {
productKey: payload.productKey,
contractAddress: address
}
}),
// update ballance
Web3ProviderActions.getBalance()]
}),
catchError((err: Error) =>
of(ErrorActions.errorMessage({ errorMsg: err.message }), SpinnerActions.hide(),
// update ballance
Web3ProviderActions.getBalance())
)
)
})
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment