rxjs

Async Subject

Async Subject

In this tutorial, we will learn about the Async Subject of RXJS.

Async Subject

A variant of Subject that only emits a value when it completes. It will emit its latest value to all its observers on completion.

import { AsyncSubject} from 'rxjs';

mySubject = new AsyncSubject();

this.mySubject .next(1);
this.mySubject .next(2);
this.mySubject .next(3);
this.mySubject .next(4);

 setTimeout(() => {
    this.mySubject.complete();
  }, 1000);

mySubject.subscribe(res => {
  console.log(res);
});






It will Output:

4

If You Appreciate What We Do Here On TutsCoder, You Should Consider:

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Leave a Comment