State class is more general concept #254
Comments
Hi, I added undo/redro to Do you think it should be added to |
I am not entirely sure if this kind of encapsulation is needed here. I am afraid another @PetrSnobelt - as per your example, it actually gave me another idea - when having a single app state - it might be unnecessary to implement redo/undo capabilities to all the items (this may cause some bugs or unwanted actions). Although
WDYT? |
@grabbou check the pull request hleumas@f3a0b44 You can simply dump the |
It makes more sense now! Thanks for the example! Atom & Cursor make a lot of sense, unlike Atom & state :) I believe we should refactor this out from Este and publish under separate org repo so others can profit as well! |
@grabbou makes sense. Will create separate repo with more immutable helpers. |
Nice, you can give me link later on so maybe i can help. |
@grabbou Here it is. All suggestions welcome! https://github.com/vacuumlabs/immutable-utils |
Hi @hleumas, are there benefits of using custom cursor implementation over Immutable contrib cursor? https://github.com/facebook/immutable-js/tree/master/contrib/cursor |
@PetrSnobelt yes, Immutable contrib cursor mixes concepts of |
@hleumas Can you summarize why we should add more abstraction to current solution? Every abstraction has to have pretty good reason to entre. Also https://twitter.com/swannodette/status/603970083870920704 "Next om will have no cursors." |
@steida It is nice to work with immutable data structures, but you need to have something mutable in your code, because our apps have state. Thats the reason you created That's the reason why in Clojure there are If you take a look at the current Este currently uses cursors. If you want to dump them entirely, I will be happy to see the solution. I am really curious how om will drop cursors. I just created Look, whole code is really simple. It's just two classes, each of them having two one-line long methods and some declaration boilerplate. It is actually less code than |
Sorry, but I don't really see an advantage of this abstraction. |
@steida let's say I renamed |
I like design principle behind PR, but overal it's too noisy for Este. We really don't want such facades like https://github.com/vacuumlabs/immutable-utils/blob/master/src/functions.js Would you force developer to debug/think about it? What if immutable api will change? This is no go. Also, there is no reason to change current api (like deref), for sake of familiarity with David's OM. Current global app state management is intentionally placed in one class. It must be easy to reason about, and spliting state and cursor is not worth it. |
+1, basically what I said before, I just don't think this kind of abstraction is needed here, we aim to avoid |
@steida https://github.com/vacuumlabs/immutable-utils/blob/master/src/functions.js is separate thing. They are not needed for the PR, I just think it is convenient to have function equivalents for Immutable methods, but it is separate issue and I can separate this to distinct repositories if you like. If we discard functions.js, you can think about the resulting code as a refactor of |
Let's become familiar with Clojure atom:
http://clojure.org/atoms
It is very similar to este
State
.atom
State
In both Clojure and Este,
atom
/State
can be watched and should contain immutable values. In both of them, they can be watched for changes.However, I think it makes sense to separate the concepts of
atom
andState
. First one should be thought about as general data structure, second is container for our application state. The latter needs some additional functionality beyond theatom
(like cursors) and these should be separated.Let's create general purpose class
Atom
with a subset ofState
methods:set
,get
, andconstructor
. That's it. Noload
,toConsole
,save
, norcursor
.The text was updated successfully, but these errors were encountered: