Fork me on GitHub
#om
<
2015-09-18
>
acron07:09:50

mattly: there's no way, afaik, to go back up the tree from a sub-cursor. ref-cursors were partly introduced to fix the problem you're describing...but I have been reassured by people that ref-cursors should be avoided and perhaps a different approach is what's actually required

grav12:09:42

I got pretty confused the other day, since I couldn’t marshall a nested data structure with Transit. If I printed it out in the repl, it looked sane enough, but Transit didn’t like it.

grav12:09:04

The reason was that there was an Om Map Cursor nested inside somewhere.

grav12:09:05

How should I deal with such a thing? It confuses me that I do not need to deref the nested map cursor in order to print it in the Repl, but I do need to do special handling in order to marshal it with Transit. How come?

dnolen12:09:54

@grav yeah that would be an issue. But fortunately not a very challenging one. Add a handler for MapCursor and IndexedCursor.

dnolen12:09:34

you probably don’t even need to do that

dnolen12:09:05

just map MapCursor -> MapHandler and IndexedCursor -> VectorHandler

grav12:09:35

@dnolen: With that solution, the issue isn’t particularly challenging, you’re right there 😉

grav12:09:00

Anyway, it was more a question of my confusion about the different behaviour of writing something to the repl versus writing it to an http request.

grav12:09:22

But thanks for the pointer simple_smile

dnolen12:09:17

@grav it’s because cursors are printable

dnolen12:09:32

being printable doesn’t make them magically transit encodeable simple_smile

grav12:09:17

ah, ok. would some kind of indication that they are cursors be a good feature? like you have with regular atoms? that would probably have cleared things up for me earlier

grav12:09:31

ie

cljs.user=> (atom {})
#object [cljs.core.Atom {:val {}}]
cljs.user=> (om.core/root-cursor (atom {}))
{}

grav12:09:47

a root cursor is just printed as if it is a regular map.

dnolen12:09:17

@grav not going to do that

dnolen12:09:39

needless breaking change, and in general not spending any more time on cursor stuff

grav12:09:20

alright.

dnolen12:09:38

@grav to clarify, some people may be using pr-str and EDN transport

dnolen12:09:47

not going to break that just because somebody wants Transit

dnolen12:09:55

or is confused by REPL behavior

grav12:09:28

right, point taken!