Level Up Coding

Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev

Follow publication

Member-only story

Bad practices you should avoid using Angular

Rebai Ahmed
Level Up Coding
Published in
4 min readNov 9, 2022

Source: https://codeburst.io/three-best-angular-js-4-online-courses-3234a65dabfd

❌ Don’t do: Put the logic being handled in tap with empty subscribe

Don’t put the logic you will implement inside the tap operator, and keep the subscribe empty in case you will have many subscribers to your observable.

Why?: the tap operator is used mostly for side-effects like caching or logging and if you put your logic there, every subscriber will call the tap logic even no need for it

But!: It’s not a generic rule, it depends in your use case, if you want really all subscribers has this logic or you will have only one subscriber and you want to use the “async pipe” then my rule does not apply.

Code-Example:

Solution: use subscribe for logic, not tap

Don’t do ❌: Error functions in a subscription are just a console.error

Don't use console.error

For error handling, because logging only the error does not throw the error, and to know that something failed and your observable cannot continue execution

Solution: Use the provided Rxjs operators for error-handling to gracefully handle errors and retry logic

Don’t do ❌: some 3–4k line components

Don't put everything in only one component, because:

  • Hard to do refactor
  • Bad readability for other devs

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (12)

Write a response