reatom icon indicating copy to clipboard operation
reatom copied to clipboard

What is difference between reatom and other libs?

Open xgrommx opened this issue 5 years ago • 9 comments

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)

xgrommx avatar Oct 19 '19 21:10 xgrommx

Thanks for your question!

All reactive libraries that you describe have two few problems:

  1. 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).
  2. 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.
  3. Observables do not follow ACID principles and encouraging inconsistency data when an error occurs.
  4. 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.

artalar avatar Oct 19 '19 22:10 artalar

@xgrommx I add the third problem after some thought

artalar avatar Oct 19 '19 23:10 artalar

@artalar can u solve Dining philosophers problem in reatom via join patterns approach?

xgrommx avatar Oct 19 '19 23:10 xgrommx

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

xgrommx avatar Oct 19 '19 23:10 xgrommx

@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 avatar Oct 19 '19 23:10 artalar

@artalar Sure, https://baconjs.github.io/api.html#join-patterns-and-baconbus

xgrommx avatar Oct 19 '19 23:10 xgrommx

@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 avatar Oct 20 '19 00:10 artalar

@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

xgrommx avatar Oct 20 '19 01:10 xgrommx

@artalar this is simple example for join patterns (via when) https://codepen.io/xgrommx/pen/qdyErQ

xgrommx avatar Oct 20 '19 02:10 xgrommx

@xgrommx are you still interested? If so please create a topic in Discussions.

BANOnotIT avatar Mar 14 '23 13:03 BANOnotIT