RxJS - Loading indicator RxJS - Loading indicator angularjs angularjs

RxJS - Loading indicator


I like transforming the request/response streams into a single stream that represents the current state of your loading property:

const startLoading$ = loadRequestSource.map(() => true);const stopLoading$ = loadResponseSource.map(() => false);const loadingState$ = Rx.Observable.merge(startLoading$, stopLoading$);// Finally, subscribe to the loadingState$ observableloadingState$.subscribe(state => {    $scope.$applyAsync(() => $scope.loading = state);});