Created
September 22, 2019 18:12
-
-
Save alexytiger/566f5bfb2e35be8121afdca8a24d8489 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 to deactivate contract: ${contract.productKey}?`, | |
| output: contract.contractAddress | |
| }; | |
| const dialogRef = this.dialog.open(ConfirmDialogComponent, dialogConfig); | |
| return dialogRef.afterClosed(); | |
| }), | |
| exhaustMap(result => { | |
| if (result === undefined) { | |
| return of(SpinnerActions.hide()); | |
| } | |
| return this.purchaseSrv.abortPurchaseContract(result).pipe( | |
| tap(address => console.log(`Successfully canceled contract: ${address} `)), | |
| concatMapTo( | |
| [PurchaseContractActions.abortSelectedPurchaseContractSuccess(), | |
| // 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