Closed Nxt3 closed 6 years ago
@rintoj
I have something like this:
@action() public searchBatches(state: AppState, payload: SearchBatchesAction): Observable<AppState> { return Observable.create((observer: Observer<AppState>) => { observer.next({ hasError: false, isLoading: true }); this.eventListService.fetchEvents(payload.batchId).subscribe( (e: Array<EventLogModel>) => { observer.next({ batchId: payload.batchId, events: e || [], isLoading: false }); }, error => { console.log('errored out'); observer.next({ events: [], isLoading: false, hasError: true }); } ); observer.complete(); }); }
but if there is an error, it never goes inside the error block. How am I supposed to do this?
error
The problem I was having was calling observer.complete() outside of the subscription. I got this working now.
observer.complete()
@rintoj
I have something like this:
but if there is an error, it never goes inside the
error
block. How am I supposed to do this?