Created
September 28, 2019 12:56
-
-
Save alexytiger/74467b5c36d585e79901cedb1a3d32d5 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
| 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(); | |
| }), | |
| exhaustMap(result => { | |
| if (result === undefined) { | |
| return of(SpinnerActions.hide()); | |
| } | |
| return this.fleaSrv.removePurchaseContract(result).pipe( | |
| tap(productKey => console.log(`Contract has been removed: ${productKey}`)), | |
| concatMap(productKey => | |
| [PurchaseContractActions.removePurchaseContractSuccess({ key: productKey }), | |
| // 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