reatom
reatom copied to clipboard
What is difference between reatom and other libs?
I have some experience with reactive programming (Rx, Bacon, Flyd, etc) What is difference between join patterns with subjects from Rx? What is difference between focal? (https://github.com/grammarly/focal)
As for me better solution is reactive join patterns (I hate redux with imperative constructions)
Thanks for your question!
All reactive libraries that you describe have two few problems:
- Stateful approach that forces you to think more about memory leaks. Reatom's atoms are stateless, just like features (example). It much more reusable: defining it once and reusing it in different contexts - stores (SSR is the main example).
- Observables notify it children (subscribers) by a depth, that can generate glitches - it wastes performance and may spawn inconsistency... In Reatom atoms updates always by right order and has no glitches.
- Observables do not follow ACID principles and encouraging inconsistency data when an error occurs.
- Observables definitions are more flexible and imperative than atoms declarations. It possible to create cyclic dependencies and encouraging you to separate model (of an application or domains) definitions to different parts of code, that not much predictable. This is a controversial argument, but I have to voice it.
focal
Totaly different library about friendly reactive bindings to view (JSX-specific). Reatom is a framework-agnostic / any subscriber-agnostic state manager for efficiently calculate derived state and to give it away reactively.
@xgrommx I add the third problem after some thought
@artalar can u solve Dining philosophers problem
in reatom via join patterns approach?
For example in Bacon.js exists update
method. This is really correct version of join patterns in js libs about reactive programming
In Rx we can emulate it https://github.com/xgrommx/react-rx-flux/blob/master/src/rx-extensions.js
In most.js also we can do almost the same
@artalar can u solve Dining philosophers problem in reatom via join patterns approach?
@xgrommx do you have some implementation by Rx or whatever, that I can try rewrite to Reatom?
@artalar Sure, https://baconjs.github.io/api.html#join-patterns-and-baconbus
@xgrommx sorry, maybe I don't understand the task completed, but it is resolution? https://codesandbox.io/s/reatom-diningphilosophersproblem-vdvv2
I'm not familiar with Bacon API, so maybe my implementation is not fully mirroring Bacon's logic...
@artalar
Bacon variant
// philosopher 0 eating
// philosopher 0 thinking
// philosopher 2 eating
// philosopher 2 thinking
// philosopher 1 eating
// philosopher 1 thinking
// philosopher 0 eating
// philosopher 0 thinking
// philosopher 2 eating
// philosopher 2 thinking
// philosopher 1 eating
// philosopher 1 thinking
// philosopher 0 eating
// philosopher 0 thinking
// philosopher 2 eating
// philosopher 2 thinking
// philosopher 1 eating
// philosopher 1 thinking
Your variant
// philosopher 0 eating
// philosopher 1 eating
// philosopher 2 eating
// philosopher 0 thinking
// philosopher 0 eating
// philosopher 1 thinking
// philosopher 1 eating
// philosopher 2 eating
// philosopher 2 thinking
// philosopher 0 thinking
// philosopher 1 thinking
// philosopher 2 thinking
@artalar this is simple example for join patterns (via when
)
https://codepen.io/xgrommx/pen/qdyErQ
@xgrommx are you still interested? If so please create a topic in Discussions.