Does MobX Observables have anything to do with RxJS ones?
Answer a question
The title is pretty much self explaining. I can't find any info about it. Angular uses RxJs observables under the hood is the same going on in React and MobX particularly?
Answers
From what I see in the MobX source code, there aren't many overlaps. Neither of them uses each other or has a common dependency with the other.
The interpretation of Observable in MobX seems to be that objects, arrays, maps, etc. are wrapped with a Proxy object to track and be notified on property changes. This is used for communicating state changes through the application while changing relatively little to the vanilla javascript types (which is probably what they mean by "transparent"). While these types may be observable (as in the verb), they are not an implementation of Observables defined by ReactiveX.
RxJS on the other hand, provides a completely new, some would say huge, API that is used to modify so-called "notifications" generated by abstract Observable types that don't necessarily represent vanilla javascript types. Instead of directly changing objects imperatively, a "LINQ-ish" language, made up of pipeable operators, is used to express execution flows. In many ways, RxJS can be seen as an language extension for JavaScript to enable Reactive programming as defined in the Observable contract.
There is one overlap though and that is the claim of "MobX" to be a library that is used for
transparently applying functional reactive programming
RxJS too provides reactive programming, but it's definitely not transparent.
更多推荐
所有评论(0)