Signal Stores in Services
Hold app state in signal-based services.
Signals as State
Angular signals are reactive values that notify consumers when they change. A signal holds a value and re-runs any computation or template that reads it.
Storing signals inside an @Injectable service lets multiple components share the same reactive state.
A Minimal Signal Store
Create a service and hold the state in a signal(). Keep the writable signal private and expose a read-only view.
import { Injectable, signal } from '@angular/core';
@Injectable({ providedIn: 'root' })
export class CounterStore {
private _count = signal(0);
readonly count = this._count.asReadonly();
increment() { this._count.update(c => c + 1); }
}All lessons in this course
- Signal Stores in Services
- Deriving State with computed
- Updating State Immutably
- Connecting Signals and RxJS