Why using RxJS with XState? #1857
-
This may be a bit off topic and a completely noob question, but I've been looking into RxJS recently (mostly because I seen David mentioning it many times in older presentations) and though I'm finding it really fascinating, it's not clear to me where/why I would use it with XState. I wasn't familiar to the concept of observers until I started using XState and from what I understood the XState service is implemented as an observable, is that right? That being the case, what are the benefits of bringing RxJS into the picture? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Practically speaking, if you don't know why you would use RxJS with XState, do not use RxJS with XState. This is one of those things where you'll know when you need it, and most of the time, you won't. But if you're curious, RxJS allows you to create complex streams of values, which can be turned into a stream of events, which can be invoked in XState; and the opposite is true, too: if you're already using RxJS in your app, it's helpful to know that XState services can be consumed as observables. |
Beta Was this translation helpful? Give feedback.
Practically speaking, if you don't know why you would use RxJS with XState, do not use RxJS with XState.
This is one of those things where you'll know when you need it, and most of the time, you won't.
But if you're curious, RxJS allows you to create complex streams of values, which can be turned into a stream of events, which can be invoked in XState; and the opposite is true, too: if you're already using RxJS in your app, it's helpful to know that XState services can be consumed as observables.