Subject

An Observable you can push values into yourself.

What is Subject?

A Subject is an Observable you can push values into yourself with next(). BehaviorSubject also remembers its latest value. Signals now cover many of its old uses.

private cartCount = new BehaviorSubject(0);
count$ = this.cartCount.asObservable();

add() { this.cartCount.next(this.cartCount.value + 1); }

Level: Freelancer · More Angular terms at this level

Updated