29
loading...
This website collects cookies to deliver better user experience
Array.map
instead of Array.forEach
”, but rather write “can we please change Array.forEach
to Array.map
?”extends
keyword, examine if that is the case; if so, propose to refactor the class to use object composition/dependency injection instead of inheritance (remember, inheritance is an is-a relationship, not a has-a one)Observables
, but sometimes there are situations it is necessary, but if you have more than one subscription, be careful to examine all of them to see if some can be refactored to just use the async pipeObservable
pipe
- usually lots of operators are not a problem, but sometimes they can introduce unnecessary complexity, and some operators have alternatives that do the same thing as a combination of 2Observable
stream - be careful to notice any occurrences of the “this” keyword inside the operator callbacks, as usually this is not something to be encouraged; when noticing such instances, examine thoroughly why the component state was referenced and if/how it can be refactored. One way is to see if the properties changed inside the Observable
pipeline are being displayed in the template; if so, use the async
pipe. In general, avoid modifying to the this
context of a component in Observables, unless it is by calling a third-party imperative function (like FormControl.disable
, for example)Subjects
- Subjects are often used to transport data from one part of application to another, and again can be abused to introduce unnecessary complexity into a system. Sometimes usage of a Subject can be discarded completely29