896 B
896 B
RxJS
- Use RxJS for asynchronous streams, events and complex reactive flows.
- Do not use RxJS when simple synchronous signals are sufficient.
- Prefer declarative observable pipelines.
- Avoid nested
subscribe. - Avoid manual subscriptions where
async, signals or framework helpers are sufficient. - Bind every manual subscription's lifetime with
takeUntilDestroyedor equivalent Angular lifecycle integration to avoid leaks. - Use the correct flattening operator for the required semantics.
- Do not use
switchMap,mergeMap,concatMaporexhaustMapinterchangeably. - Avoid unnecessary
Subjectusage. - Prefer exposing observables instead of exposing mutable subjects.
- Prefer
BehaviorSubjectonly when a current value is actually required. - Avoid excessive observable chains for simple state.
- Avoid converting repeatedly between signals and observables without need.