On Thu, Apr 10, 2014 at 8:51 AM, Nikita Prokopov <[email protected]> wrote:

>
> To get cursor that points at primitive value, wrap it into vector of 1
> element: (def state (atom {:timer [0]}))
>

Your understanding is correct except for this point. Don't do this. Cursors
on primitive values are simply discouraged unless you have a really,
really, really good reason. And even then ... don't do it!


> What’s not clear for me:
>
> David, you often mentioned that outside render phase, you cannot do
> anything with cursors besides deref/update/transact. But for me these
> operations covers everything we need. Can you name what operations are
> prohibited outside render phase?
>

You can't do collection operations of any kind, you cannot print -
basically anything that involves inspecting the contents of the cursor that
were available during render.


> Also you mentioned that there’s two type of values underneath cursor:
> stale value and current value. Can you describe via which calls they can be
> accessed?
>

om.core/value outside of render will deliver last known *rendered* value.
deref will give you the actual value.


> Actually, whole state consistency semantic is not clear. What are points
> when state can be changed? Which changes and when become visible and for
> whom? For example, if I transact inside render, will I see changes in
> render afterwards? It would be nice to have it described in several basic
> principles.
>

If transact! update! occurs during render these changes will not be
detectable by anyone until the *next* frame. This is not true for local
state changes via set-state! these changes are immediately available to a
component.


> What to do if component depends on two or more cursors? For example, I
> render game field and have state like this: {:selected [17 18], :field
> [[...], ...]}. But each cell view depends only on one field cell and on
> selected coordinates, e.g. on two cursors: [:selected] and [:field 5 2].


Not really sure what you're asking, but this just works.

David

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