Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-04 Thread Alan Shaw
Hi, The error is: Uncaught Error: No protocol method PMagnitude.mag-squared defined for type om.core/IndexedCursor: [object Object] make-animations is a pure function that does invoke mag-squared (from @toxi's geom library) along the way. There is a factor that may be very relevant to the failur

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Daniel Kersten
Are you able to show the exception that gets thrown? Also can you perhaps share the make-animations code? It "should" work as I pass cursors around all the time without issue... The only time this causes problems for me is if I pass it to something that gets run outside the render phase (eg js/setT

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Alan Shaw
> make-animations should be able to work with (:circles cursor) without knowing or caring if it gets given a cursor or not - cursors are quite transparent. I agree that it should be able to. However it is not doing so. In the component where I am calling make-animations, the cursor is (:circles cu

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Daniel Kersten
Minor correction: did-update should be (= prev-props data). It gets the "old" cursor value as it's argument. On 4 Sep 2014 00:50, "Daniel Kersten" wrote: > I went digging and the code where I set local state to cursor data was > actually old code and I was missremembering it :-) > All of my new c

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Daniel Kersten
I went digging and the code where I set local state to cursor data was actually old code and I was missremembering it :-) All of my new code does actually strictly separate the two mechanisms so that app state refers to the domain data (the what) and local state refers to the state of widgets (the

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Jamie Orchard-Hays
Alan, if you haven't read this page, it's very helpful: https://github.com/swannodette/om/wiki/Cursors Jamie On Sep 3, 2014, at 3:21 PM, Alan Shaw wrote: > Ahh thanks! > > 2014/9/3 上午11:48 於 "David Nolen" 寫道: > It is not. Use om.core/value > > On Wed, Sep 3, 2014 at 2:29 PM, Alan Shaw w

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Alan Shaw
Ahh thanks! 2014/9/3 上午11:48 於 "David Nolen" 寫道: > It is not. Use om.core/value > > On Wed, Sep 3, 2014 at 2:29 PM, Alan Shaw wrote: > > So it is OK to take (.-value cursor) in render-state? > > > > -- > > Note that posts from new members are moderated - please be patient with > your > > fir

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread David Nolen
It is not. Use om.core/value On Wed, Sep 3, 2014 at 2:29 PM, Alan Shaw wrote: > So it is OK to take (.-value cursor) in render-state? > > -- > Note that posts from new members are moderated - please be patient with your > first post. > --- > You received this message because you are subscribed to

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Alan Shaw
So it is OK to take (.-value cursor) in render-state? -- 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 receivi

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread David Nolen
om.core/value during rendering, deref anywhere else On Wed, Sep 3, 2014 at 11:08 AM, Alan Shaw wrote: > Thanks, I will do that. In the meantime it would help me if you could > describe the conditions under which saying "cursor" provides its value > rather than the cursor object? > > 2014/9/3 上午8

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Alan Shaw
Thanks, I will do that. In the meantime it would help me if you could describe the conditions under which saying "cursor" provides its value rather than the cursor object? 2014/9/3 上午8:00 於 "David Nolen" 寫道: > I think it will be more fruitful to describe your problem with a > minimal bit of code

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread David Nolen
I think it will be more fruitful to describe your problem with a minimal bit of code completely outside the context of what you are working on. As it stands I cannot even see the trouble you are having. David On Wed, Sep 3, 2014 at 10:48 AM, Alan Shaw wrote: > OK let me try this: > > (render [_]

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Alan Shaw
OK let me try this: (render [_] (dom/h1 nil (:text app))) App is a cursor but here we are happily getting the :text member of its value by pretending app is the value. (Something something (f app)) App is a cursor but here I am not magically given its value. Discuss. 2014/9/3 上午7:41 於 "David N

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread David Nolen
Or I simply don't understand the problem or the question :) On Wed, Sep 3, 2014 at 10:30 AM, Alan Shaw wrote: > Wow you simply have not taken the time to read my question. > > 2014/9/3 上午7:28 於 "David Nolen" 寫道: > >> If for some reason you need to snapshot the value of a cursor during >> render

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Alan Shaw
Wow you simply have not taken the time to read my question. 2014/9/3 上午7:28 於 "David Nolen" 寫道: > If for some reason you need to snapshot the value of a cursor during > render use om.core/value to do that. > > David > > On Wed, Sep 3, 2014 at 10:25 AM, Alan Shaw wrote: > > Setting local state fr

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread David Nolen
If for some reason you need to snapshot the value of a cursor during render use om.core/value to do that. David On Wed, Sep 3, 2014 at 10:25 AM, Alan Shaw wrote: > Setting local state from app state was not my goal. My goal was to reflect > the changed app state in the display - not an unreasona

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Alan Shaw
Setting local state from app state was not my goal. My goal was to reflect the changed app state in the display - not an unreasonable desire. If you read my question again you'll see that setting local state was only one of three ways I tried to accomplish that. Again: I was unable to access the c

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread David Nolen
It just isn't a good idea. They are two separate state management mechanisms. You are bound to get burned eventually and it won't be pretty. It may also be disallowed completely in the future. David On Wed, Sep 3, 2014 at 8:59 AM, Daniel Kersten wrote: > David, can you give more details why? Is

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread Daniel Kersten
David, can you give more details why? Is it because what it points to may become invalid if the app-state changes? I'd have to dig up code where I've actually done it, I can't think of any offhand but I'm sure I have and haven't had any issues, but I can understand why it might be a bad idea! How

Re: [ClojureScript] [Om] Transforming cursor data for render-state

2014-09-03 Thread David Nolen
Putting cursors into state is not a good idea. On Wednesday, September 3, 2014, Daniel Kersten wrote: > > On 3 Sep 2014 06:51, "Alan Shaw" > wrote: > > > > PS My confusion is increased by the fact that if I print out next-props > from within will-receive-props, it appears on the console to be a

[ClojureScript] [Om] Transforming cursor data for render-state

2014-09-02 Thread Alan Shaw
My main app cursor has a field :circles which is a vector. My animator component's render-state method needs these circles transformed into animations. This is done by a function make-animations. The parent component invokes om/build on the animator, passing (:circles cursor) as the animator's curs