javascript - dispose/unsubscribe inside subscribe function block in rxjs -


i've subject called authenticated in _auth service.

i want dispose/unsubscribe if condition fails subscribe doesn't call when next value arrives in authenticated subject.

                this.sub = this._auth.authenticated                 .subscribe((loggedin) => {                     if (!loggedin) {                         this.sub.dispose(); // doesn't work because this.sub null                         this._location.replacestate('/');                         this._auth.dologout(); // emits value again in authenticated subject                     }                 }); 

what rxjs-5 way of doing it?

you hold reference observable eg: obs$ , call obs$.unsubscribe();


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -