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 failure to transparently
provide the cursor's value: This error is occurring on REPLAY of the app
from time-machine saved states.

-A


On Wed, Sep 3, 2014 at 11:25 PM, Daniel Kersten <[email protected]> wrote:

> 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/setTimeout or putting it on a
> core.async channel). In these cases you use om.core/value before passing
> the data to these, or you deref the data on the other side (the timeout
> function or the go block). I prefer the first option as it means the other
> functions need not know about cursors.
> On 4 Sep 2014 02:28, "Alan Shaw" <[email protected]> wrote:
>
>> > 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 cursor) of the parent component, so my call in render-state was
>> exactly this:
>> (make-animations cursor)
>> The error that this throws indicates I'm trying to invoke make-animations
>> on an actual cursor object. If I change that to
>> (make-animations (om/value cursor))
>> it behaves as hoped.
>>
>> Once again, I don't need or want to set local state from app state. That
>> was just something I tried when this more straightforward approach failed.
>>
>>
>> On Wed, Sep 3, 2014 at 4:51 PM, Daniel Kersten <[email protected]>
>> wrote:
>>
>>> 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" <[email protected]> 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 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 how). So there actually isn't any
>>>> natural overlap.
>>>>
>>>> As for Alans question, I've reread it a few times and I'm not sure I
>>>> understand what you're trying to achieve.
>>>>
>>>> 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.
>>>>
>>>> Are you trying to detect if the cursor has changed from one update to
>>>> the next?
>>>>
>>>> If yes then you can compare your current cursor to the previous one in
>>>> will-receive-props by doing (when-not (= (om.core/get-props owner)
>>>> next-props) (cursor-has-changed)) or in did-update using (when-not (=
>>>> next-props data) (cursor-has-changed)) where data is your cursor.
>>>> Use the former if you want to do this before render and the latter if
>>>> after.  Note that if you modify local state in did-update you will trigger
>>>> a rerender potentially causing a render loop (but if you only do this when
>>>> your cursor data has changed, it's not a problem because the second time
>>>> the conditional will be false).
>>>>
>>>> Hope that helps.
>>>> 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 <[email protected]> wrote:
>>>>
>>>> Ahhhhhh thanks!
>>>> 2014/9/3 上午11:48 於 "David Nolen" <[email protected]> 寫道:
>>>>
>>>>> It is not. Use om.core/value
>>>>>
>>>>> On Wed, Sep 3, 2014 at 2:29 PM, Alan Shaw <[email protected]> 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 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.
>>>>>
>>>>
>>>> --
>>>> 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.
>>>>
>>>  --
>>> 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.
>>
>  --
> 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.

Reply via email to