Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Last active February 19, 2020 01:05
Show Gist options
  • Save alexytiger/8c522686dbb32e9a7a991f3fb32cd2b2 to your computer and use it in GitHub Desktop.
Save alexytiger/8c522686dbb32e9a7a991f3fb32cd2b2 to your computer and use it in GitHub Desktop.
e-book
removeProduct$ = createEffect(
() =>
this.actions$.pipe(
ofType(PurchaseContractActions.removePurchaseContract),
map(payload => payload.key),
switchMap(key => {
const dialogConfig = new MatDialogConfig();
dialogConfig.width = '420px';
dialogConfig.disableClose = true;
dialogConfig.autoFocus = true;
dialogConfig.data = {
title: 'Confirm Remove',
content: `Are you sure to remove contract ${key} from market?`,
output: key
};
const dialogRef =
this.dialog.open(ConfirmDialogComponent, dialogConfig);
return dialogRef.afterClosed();
}),
filter(result => !!result),
exhaustMap(result => concat(
of(SpinnerActions.show()),
this.fleaSrv.removePurchaseContract(result).pipe(
tap(productKey =>
console.log(`Contract has been removed: ${productKey}`)),
concatMap(productKey =>
[PurchaseContractActions.removePurchaseContractSuccess(
{ key: productKey }),
Web3ProviderActions.getBalance()]
),
catchError((err: Error) =>
of(this.handleError(err), SpinnerActions.hide(),
Web3ProviderActions.getBalance())
)
),
of(SpinnerActions.hide()),
))
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment