this doing now, , wonder if there better way
this.dataservice.subscribe( data => this.data = data, error => alert('something went wrong'), () => this.dosomethingoncompletion());
if i'm not catching data, however, might alter first of 3 functions:
() => null,
the documentation rxjs 4.x doesn't answer question enough me. version 5.x explains less.
so, verdict? following wrong when need nothing more trigger happen?
this.dataservice.subscribe( () => null, error => alert('boom.'), () => this.dosomethingoncompletion());
if didn't need on completion, i'd leave part out. if wanted check errors , nothing else?
rxjs 4 if need errors
can use subscribeonerror
method handles errors.
you can use subscribe method well, need pass null value handlers don't want, don't have pass own noop.
this.dataservice.subscribe( null, error => alert('something went wrong'));
rxjs 5 can pass so-called partialobserver
:
this.dataservice.subscribe({ error: error => alert('boom.'), complete: () => this.dosomethingoncompletion() })
Comments
Post a Comment