Skip to content

Instantly share code, notes, and snippets.

@alexytiger
Last active February 19, 2020 00:53
Show Gist options
  • Save alexytiger/64cb169f927a6fefdc3835bcee4b8fdc to your computer and use it in GitHub Desktop.
Save alexytiger/64cb169f927a6fefdc3835bcee4b8fdc to your computer and use it in GitHub Desktop.
e-book
abortContract$ = createEffect(
() =>
this.actions$.pipe(
ofType(PurchaseContractActions.abortSelectedPurchaseContract),
withLatestFrom(
this.store$.pipe(select(fromStore.getSelectedPurchaseContract))),
switchMap(([action, contract]) => {
const dialogConfig = new MatDialogConfig();
dialogConfig.width = '420px';
dialogConfig.disableClose = true;
dialogConfig.autoFocus = true;
dialogConfig.data = {
title: 'Confirm Abort',
content: `Are you sure you want to deactivate contract:
${contract.productKey}?`,
output: contract.contractAddress
};
const dialogRef =
this.dialog.open(ConfirmDialogComponent, dialogConfig);
return dialogRef.afterClosed();
}),
filter(result => !!result),
exhaustMap(result => concat(
of(SpinnerActions.show()),
this.purchaseSrv.abortPurchaseContract(result).pipe(
tap(address =>
console.log(`Successfully canceled contract: ${address} `)),
concatMapTo(
[PurchaseContractActions.abortSelectedPurchaseContractSuccess(),
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