Last active
February 19, 2020 01:05
-
-
Save alexytiger/8c522686dbb32e9a7a991f3fb32cd2b2 to your computer and use it in GitHub Desktop.
e-book
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(); | |
}), | |
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