Hi folks,

This is mostly aimed at David Nolen I suppose, but I think others may
have experience with this, and will want to think through and discuss
this.  I'm talking about Om v0.5.3 here, except when I mention otherwise.

I mentioned in a recent Om-related thread
(https://groups.google.com/forum/#!topic/clojurescript/SiRxM0HSoRk) that
we have a slightly different data update strategy, compared to what
seems to be the implied use-case, in our Om-based app: we receive delta
updates via server-push from outside of the app.  We call transact! and
update! relatively infrequently; but we do update the initially set atom
we pass into root from outside--out of necessity based on our architecture.

Of course what happens whenever an update occurs from the outside is
that any cursors that were passed into components that are affected by
those updates get wiped out and replaced by basic Clojure data
structures.  Om components don't complain--of course, a lot of what
cursors are are wrappers around the base functionality in Clojure data
structures.  But there are problems whenever there are state updates in
those components affected.

Additionally, there are cases where we do a lot of data manipulation to
get cursor data into the right format for a child component--it's
neither possible nor desirable for us to format our data before loading
it into root.  But again this wipes out cursors in child components and
calls to set-state! and etc. will throw errors.

We can use the fn arg in build options, but that will then potentially
wipe out the cursor for *child* components
(https://github.com/swannodette/om/blob/master/src/om/core.cljs#L604-L607).

Because we are processing data within components, it also so happens
that we will sometimes have nil values get passed into components; I've
been apathetic about handling those because it seems like there are no
issues--however, now I'm not sure what is appropriate behavior for a nil
value getting passed into a component, or if actually I should have been
testing for that all along--I haven't because I've gotten no errors
related to this.

I didn't actually realize this was happening until recently when I
started seeing some bugs with complaints about lack of -path in cursors,
and started digging into the codebase and realized what was going
on--I'd been blissfully ignorant before, because everything had been
working so smoothly.

During the course of reading through Om's code, I saw that in newer
versions of build, code has been added to mitigate this
problem--integrating graft into build by default:

https://github.com/swannodette/om/blob/master/src/om/core.cljs#L586-L589

So I guess this problem will go away...?  But perhaps more to the point,
what is the right approach with a model such as ours--should we have
been using graft all along for this?  I would rather have this handled
automatically--so I can always be assured I have a proper cursor in a
component.

Thanks for reading this far--I would love to hear what David and anyone
else with experience dealing with this has to say.

Best,
Dave

-- 
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.

Reply via email to