Last active
November 12, 2019 22:52
-
-
Save peterbsmyth/1349e74a91de7e36b0055319ae6b942c to your computer and use it in GitHub Desktop.
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
@Injectable() | |
export class Effects { | |
getPending$ = createEffect(() => | |
this.actions$.pipe( | |
ofType(ApprovalActions.getAllPendingApprovals), | |
switchMap(res => | |
this.apiService.getAllPendingApprovals() | |
), | |
map((approvals) => ApprovalActions.getAllPendingApprovalsComplete({ approvals })) | |
) | |
); | |
savePhoto$ = createEffect(() => | |
this.actions$.pipe( | |
ofType( | |
NewExpenseActions.takePhotoComplete, | |
NewExpenseActions.selectPhotoLibraryComplete | |
), | |
tap(() => { | |
this.routerExtensions.navigateByUrl('/create-expense', { clearHistory: true }); // MOBILE ONLY | |
}), | |
switchMap(({ uri }) => this.apiService.saveOneExpenseReceipt(uri)), // MOBILE ONLY | |
map((token) => NewExpenseActions.savePhotoComplete({ token })) | |
) | |
); | |
constructor( | |
private actions$: Actions, | |
private apiService: ApiService | |
) { } | |
} |
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
@Injectable() | |
export class Effects { | |
getPending$ = createEffect(() => | |
this.actions$.pipe( | |
ofType(ApprovalActions.getAllPendingApprovals), | |
switchMap(res => | |
this.apiService.getAllPendingApprovals() | |
), | |
map((approvals) => ApprovalActions.getAllPendingApprovalsComplete({ approvals })) | |
) | |
); | |
openModal$ = createEffect(() => | |
this.actions$.pipe( | |
ofType(ModalActions.openModal), | |
tap(({ name }) => { | |
this.modalService.open(name); // WEB ONLY | |
}) | |
), { dispatch: false } | |
); | |
constructor( | |
private actions$: Actions, | |
private apiService: ApiService, | |
private modalService: BaseModalService | |
) { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment