W
W
waltaki2020-11-27 13:35:12
Angular
waltaki, 2020-11-27 13:35:12

RxJS - How to get subscriber only new values?

Hello.

How to make sure that the subscriber does not receive old values, but only expects new ones (in my case, one).

const sbj = new ??Subject<number>();

sbj.next(2);
// Не будет обработан подписчиками

sbj.subscribe(vl => console.log(`1st: ${vl}`));
sbj.subscribe(vl => console.log(`2nd: ${vl}`));

sbj.next(7); 
// 1st: 7
// 2nd: 7

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2020-11-27
@waltaki

const sbj = new Subject<number>();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question