devyumao / angular2-busy

Show busy/loading indicators on any promise, or on any Observable's subscription.
http://devyumao.github.io/angular2-busy/demo/asset/
MIT License
314 stars 102 forks source link

angular2-busy not working when calling Observer.error() #83

Open samih-dev opened 7 years ago

samih-dev commented 7 years ago

Hi,

I'm having the following code testing the module:

`import { Component, OnInit } from '@angular/core'; import { Subscription } from "rxjs/Subscription"; import { Observable } from "rxjs/Observable"; import { Observer } from "rxjs/Observer"; import { IBusyConfig } from "angular2-busy"; import 'rxjs/add/operator/delay';

@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit { busyConfigSettings: IBusyConfig busy: Subscription; ngOnInit(){

this.busyConfigSettings = {
  delay: 0,
  minDuration: 0,
  message: 'loading...',
  busy: null,

}

this.busyConfigSettings.busy = this.generateObservable().subscribe(
  () => { // success
    console.log('logic for success');
  },
  () => { // error 
    console.log('logic for error');
  },
  () => { // complete
    console.log('logic for compelete');
  });

}

generateObservable(): Observable{ return Observable.create((observer: Observer) => { observer.error("Notify about error, expecting loader to be hidden after this."); // observer.next(null); observer.complete(); }).delay(5000); } } `

calling Observer.next is working as expected, but when trying to call observer error, loading isn't showing at all, and sometimes I got exception regarding the change detection for Angular.

Any help? seems not supported.