Last active
February 8, 2020 20:26
-
-
Save alexytiger/b5ee22faa5feb332a889b67a865de654 to your computer and use it in GitHub Desktop.
e-book
This file contains 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
confirmDelivery$ = createEffect( | |
() => | |
this.actions$.pipe( | |
ofType(PurchaseContractActions.confirmDelivery), | |
withLatestFrom(this.store$.pipe(select(fromStore.getSelectedPurchaseContract))), | |
switchMap(([payload, contract]) => { | |
const dialogConfig = new MatDialogConfig(); | |
dialogConfig.width = '420px'; | |
dialogConfig.disableClose = true; | |
dialogConfig.autoFocus = true; | |
dialogConfig.data = { | |
title: 'Confirm Delivery', | |
content: `Are you sure you want to confirm that you received the purchase item ${contract.description}`, | |
output: contract.contractAddress | |
}; | |
const dialogRef = this.dialog.open(ConfirmDialogComponent, dialogConfig); | |
// Gets an observable that is notified when the dialog is finished closing. | |
return dialogRef.afterClosed(); | |
}), | |
filter(result => !!result), | |
exhaustMap(result => concat( | |
of(SpinnerActions.show()), | |
this.purchaseSrv.confirmDelivery(result).pipe( | |
tap(address => console.log(`Delivery confirmed successfully for the contract: ${address} `)), | |
concatMapTo( | |
[PurchaseContractActions.confirmDeliverySuccess(), Web3ProviderActions.getBalance()] | |
), | |
catchError((err: Error) => | |
of(this.handleError(err), Web3ProviderActions.getBalance()) | |
) | |
), | |
of(SpinnerActions.hide()), | |
)) | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment