tatsu
tatsu

Reputation: 2536

Rxjs : how it's done and async/await

I have Observables, Subjects and ect thanks to rxjs,

good, I don't need async/await : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function

My question is how do the guys who made rxjs do what they do?

did they use the async function to create their library or did they find a much more optimal solution?

If they did use that function it means, for example that I couldn't use rollupjs bundler with rxjs correct?

Upvotes: 0

Views: 170

Answers (1)

Artem Arkhipov
Artem Arkhipov

Reputation: 7455

Underneath, they use the observer pattern which actually does not need async/await or promises to implement. For example, when you have a DOM element and add some event listeners to it - you already use the simple observer implementation and it doesn't brake anything.

Also, here is a nice short article explaining it with an examples in Javascript.

You may use any bundler you want with, rxjs library can not brake it.

Note, that you can convert an observable to promise if you need with a toPromise operator.

Upvotes: 1

Related Questions