Last active
October 21, 2016 08:03
-
-
Save franciscotln/6d8dc4c55076afb201cb0c2843280e53 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
// why are you passing this 'currentStatus' from the view (first element in the array) if it's | |
// not being used here anywhere? You only use status and productId to dispatch the action; | |
// BTW: don't use array indices like arr[0], arr[1] ;-) that's not the reactive way. | |
this.onReject$ | |
.switchMap(([currentStatus, status]: string[]): Observable<any> => | |
this.product$.filter(Boolean).first().map((product: any) => { | |
const productId = product.get('id'); | |
return { currentStatus, status, productId }; | |
}) | |
) | |
.switchMap(({ status, productId }: any): Observable<boolean> => { | |
this.productStatusesActions.reject(status, productId); | |
return this.isProductRejectSuccess$.filter(Boolean); | |
}) | |
.subscribe(() => this.router.navigate(['/dashboard/product-ideas/products'])); | |
this.onReadyToSell$ | |
.switchMap(([currentStatus, status]: string[]): Observable<any> => | |
this.product$.filter(Boolean).first().map((product: any) => { | |
const productId = product.get('id'); | |
return { currentStatus, status, productId }; | |
}) | |
) | |
.switchMap(({ status, productId }: any): Observable<number> => { //productId is a number or string? Change the type here | |
this.productStatusesActions.readyToSell(status, productId); | |
return this.isProductReadyToSellSuccess$ | |
.filter(Boolean) | |
.switchMapTo(Observable.of(productId)); | |
}) | |
.subscribe((productId: number) => this.productActions.calculateELC(productId)); | |
/** | |
* skipUntil won't work because the source emits one value and then completes | |
* so it skips the first - and only - item of the source observable | |
* and waits for more value but no more values will come so you'll never hit the subscribe(). | |
* It's like doing Observable.of(1).skipUntil(Observable.empty()).subscribe(console.log) | |
* The number 1 will never be passed to the subscriber. | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment