Skip to content

Instantly share code, notes, and snippets.

@raloliver
Created September 27, 2019 15:53
Show Gist options
  • Save raloliver/2de84dffbca099e8af8f31a58207c254 to your computer and use it in GitHub Desktop.
Save raloliver/2de84dffbca099e8af8f31a58207c254 to your computer and use it in GitHub Desktop.
RxJS: AsyncSubject, BehaviorSubject and ReplaySubject
var subjectAsync = new Rx.AsyncSubject();
var subscriptionAsync = subject.subscribe(
value => console.log(`My Value is ${value}`),
err => console.log(`Error message: ${err}`),
() => console.log('Completed!')
)
var counterAsync = 5,
interval = setInterval(()=>{
subject.next(counter--);
if(!counter){
clearInterval(interval);
subject.complete()
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment