Om ref cursors (and ref-sub-cursor)

174 views
Skip to first unread message

Todd Berman

unread,
Oct 31, 2014, 7:10:39 PM10/31/14
to clojur...@googlegroups.com
I am running into an issue where it appears that a ref-sub-cursor (https://github.com/swannodette/om/blob/master/src/om/core.cljs#L763) should implement IOmRef, as it appears that -refresh-deps! is being called against it, which won't work.

I am able to make this happen when creating a reference cursor, passing a sub cursor to a component, and then having that get passed to a third component (basically, following the editable paradigm from the tutorials).

I am still a relative newbie when it comes to the Om internals, so unclear why this is happening in one case, but not in others.

--Todd

David Nolen

unread,
Oct 31, 2014, 7:23:43 PM10/31/14
to clojur...@googlegroups.com
Sub cursors from an IOmRef instance won't themselves be IOmRefs. For
the time being we're going to stick to this.

I'd like to hear a lot more details about the use case before changing
my mind. It seems to me if you really need sub cursors to be ref
cursors you are not writing the API that you need for you application
and piggiebacking on ref cursors in an unintended way.

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 clojurescrip...@googlegroups.com.
> To post to this group, send email to clojur...@googlegroups.com.
> Visit this group at http://groups.google.com/group/clojurescript.

Todd Berman

unread,
Oct 31, 2014, 7:28:25 PM10/31/14
to clojur...@googlegroups.com
Very possible.

Basically, I have this structure:

Question
  Answer
    Editable

Question gets a cursor that it uses only to get the id of the question to show, and uses a ref-cursor to grab the actual data from a friendly API.

It then passes a sub cursor to Answer (because a Question may have N answers), which in turn uses editable.

There is one pattern (creating a new question) where I get an exception thrown because parent is null (which prompted this email, and it turns out has nothing to do with ref-sub-cursor implementing IOmRef, so I apologize for the increasingly misnamed subject).

Unclear how I get into that state, or what I can do to debug it.

—Todd



You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/AEFcjjDsHKY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.

Todd Berman

unread,
Oct 31, 2014, 7:31:04 PM10/31/14
to clojur...@googlegroups.com
Additional debugging shows that state has nothing to do with anything. When I edit the answer title of an existing question, I get the same error. It just is guaranteed to happen during creation (duh).

--Todd

Todd Berman

unread,
Oct 31, 2014, 7:40:09 PM10/31/14
to clojur...@googlegroups.com
https://github.com/swannodette/om/blob/master/src/om/core.cljs#L770 looks like the bug. It appears that it should pass parent into ref-sub-cursor, which would prevent this.

--Todd

Todd Berman

unread,
Oct 31, 2014, 8:14:07 PM10/31/14
to clojur...@googlegroups.com
I can confirm that fixes it locally. Sorry for the misleading/confused bug report!

--Todd

David Nolen

unread,
Nov 1, 2014, 6:20:22 AM11/1/14
to clojur...@googlegroups.com
Open an issue thanks!
Reply all
Reply to author
Forward
0 new messages