Angular: Avoid the Subscribe() Method for Observables

Outdated tech products on a desk.
Photo by Lorenzo Herrera on Unsplash.

What Is an Observable?

Subscribe Function

serviceFunctionReturningObservable( flag: Flag ):
Observable<boolean> {}

The suboptimal version of my code (without using an async pipe) with regular .subscribe()



Why Use AsyncPipe?

Another Example of the Principle

Initial working code with .subscribe()

Final refactored code without using .subscribe()


DataScience | ML | 2x Kaggle Expert. Ex Fullstack Engineer and Ex International Financial Analyst.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store