Overview of @ngrx/component-store concepts
mainComponentStore is a standalone library designed to manage local or component-level state. It serves as a reactive alternative to the 'Service with a Subject' pattern.
Key capabilities include:
- State Lifecycle: State is typically tied to a component's lifecycle and is cleaned up upon component destruction.
- State Initialization: State can be initialized either eagerly or lazily.
- Writing State: State updates are performed using
setStateorupdatermethods, supporting both imperative updates and Observable-based updates. - Reading State: State is accessed via
select(highly performant selectors) or a top-levelstate$observable. - Side-effects: Side-effects (both synchronous and asynchronous) are managed using the
effectmethod, which can consume data both imperatively and reactively.