thi-ng / umbrella

⛱ Broadly scoped ecosystem & mono-repository of 199 TypeScript projects (and ~180 examples) for general purpose, functional, data driven development
https://thi.ng
Apache License 2.0
3.41k stars 151 forks source link

[hdom] question about state management #238

Open Korede-TA opened 4 years ago

Korede-TA commented 4 years ago

first of all, thanks for this really cool set of libraries i've felt really productive using these so far!

context: i've been working on a small project based on the HDOM, and i've been using global variables pretty arbitrarily to represent state. i've started running into snags with state updates, which make sense since i'm now doing state updates asynchronously via the FileReader API.

Q: i'm trying to figure out which one of the state management mechanisms provided in this repo which i could most easily use as a replacement. I've toyed with the @thing/atom package, but i don't really need any undo/redo functionality or anything fancy, just something to handle this async case that requires minimal state changes. It seems like there's a bunch of different possible approaches here, so I want to figure out the best way to go about it.

nkint commented 4 years ago

Hi @Korede-TA , here it is a not exhaustive answer, hope this helps a little :)

There are few different ways of handling state managements, here some examples from the doc:

FYI there a new package for manipulating the DOM more tightly related with stream/reactive programming paradigm: thi.ng/rdom so IMHO could worth to use rstream (there are several examples with hdom).

Anyway the strength of atom package is not only for undo/redo but also in the immutable state paradigm (together with the thi.ng/paths package to have lenses over complex object).

loganpowell commented 4 years ago

+1 for rstream !