I'm still trying to figure out the best way to handle this too. I would probably put it in the global app state temporarily, but would want to be careful that transactions on it are properly tagged so that my tx-listen can ignore them for server-sync and undo history purposes.
Another possibility that I've used is to use local state for everything and have the parent pass a callback to the child, so that when the child wants to commit the data, it can pass it back using the callback. Of course, you can also pass the cursor directly, so the component stores the data in local state and then on commit, it updates the cursor. On 21 July 2014 18:25, Stefan Oestreicher <[email protected]> wrote: > Hi, > > I'm struggling a little with the global app state in Om. When decomposing > big components I find myself wanting to use a cursor around component local > state to pass to children in order to get 2-way-binding between parent and > child component but without exposing this information to the global app > state. It appears that this is not possible (actually I managed to get it > to work somewhat by creating a MapCursor manually but this is clearly a > hack since it throws errors about atom not implementing INotify or > something like that). > > As a concrete example, I want to build a form component for editing > persons. This form component takes a person object (cursor) and handles > properties common to all persons like name, age, whatever. Then I create > components for the specific properties of different kinds of persons (maybe > student and professor like in the Om example). Those components also get > the person object (cursor) and just handle editing of the specific > properties they know about. > > This is of course possible with current Om, but as far as I can tell only > if the person object lives in the global app state. This may be alright for > editing but for creating I feel that this temporary state shouldn't have to > be exposed through the global app state. And even for editing you still may > not want to modify the object in the global state but a local copy. > > Maybe I'm wrong and what I want to do is possible, or maybe I'm just > thinking about this the wrong way in the first place. I would appreciate > any advice. > > thanks > Stefan > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
