user image

Shilpa
Published in : 2022-02-28

In Angular project, RxJS isStopped is deprecated! What is the alternative?

Angular

My visual code tslint and some other extensions are installed for my angular project. While reviewing my code, It shows isStopped is deprecated. what should I use instead of isStopped?

I want to rewrite my code with latest available methodology. Deprecated functions are causing showstopper to the application sometimes!

public createPatientChart(dataItemSet: any): any {this.showLoader = true; if (!this.sbscrbr.isStopped) { this.chart = this.healthService.createPatientBMIChart(dataItemSet, this.chartId, this.optionPool, this.extendedOptions); this.showLoader = false; return this.chart; } this.showLoader = false; return null; }

Any compatible code alternative for this code block?

Comments

Rakshit Date : 2022-03-01

Best answers

34

Best answers

34

If you would like to check, whether your all subscribers (this.sbscrbr variable) are unsubscribed - In that case, RxJS introduced closed property. Here I rewrote the code for you,

 

public createPatientChart(dataItemSet: any): any {this.showLoader = true; if (!this.sbscrbr.closed) { //Use closed here to check your subscriber's state. this.chart = this.healthService.createPatientBMIChart(dataItemSet, this.chartId, this.optionPool, this.extendedOptions); this.showLoader = false; return this.chart; } this.showLoader = false; return null; }

closed will do the trick for you.

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

Static code analysis tools integration with latest Angular version
Publish date: 2022-02-25 | Comments: 1

Tag: Angular

Adding country flags is really struggling thing?
Publish date: 2022-02-25 | Comments: 6

Tag: Angular

How to reload Angular component without refreshing page?
Publish date: 2022-03-02 | Comments: 1

Tag: Angular

Import Swiper into Angular causes error
Publish date: 2022-03-05 | Comments: 1

Tag: Angular

Angular: HTML anchor tag with #idref issue
Publish date: 2022-03-01 | Comments: 2

Tag: Angular

How to translate Angular application easily?
Publish date: 2022-03-03 | Comments: 2

Tag: Angular