YUNOVA · Angular
Module 10: Advanced RxJS and state
Subject and BehaviorSubject
Key points
- A Subject is both an Observable and an Observer that multicasts values.
- A BehaviorSubject needs a starting value and replays the latest to new subscribers.
- Services often expose a BehaviorSubject as asObservable() to share state.
Higher-order mapping: mergeMap, concatMap, exhaustMap
Key points
- mergeMap runs inner observables at the same time.
- concatMap waits for each inner observable to finish, keeping order.
- exhaustMap ignores new values while one is running, e.g. double clicks.
NgRx effects and selectors
Key points
- Effects listen for actions and run side effects like HTTP calls.
- An effect usually maps its result to a success or failure action.
- Selectors read and memoise slices of the store state.
Signal store state management
Key points
- NgRx SignalStore holds state as signals.
- withState, withComputed and withMethods build up the store.
- Components read signals directly, with no subscribe or async pipe.