Hi guys,

During our last SF Reagent meetup
(http://www.meetup.com/Reactive-ClojureScript/events/221710610/  -- I still
owe you a professionally produced video), there was this interesting
perception that cursors in Reagent were just pointers and therefore
couldn't implement any transformation on the data. Maybe I misunderstood
the context but that's what I recall being said.

So I put together a quick example of how to implement inward and outward
transforms on app state atom using Reagent cursors, which are quite
powerful.

Disclaimer: I literally just learned about multi-methods a couple days ago
so I'm pretty sure I'm misusing them in some way, but that shouldn't take
away from the basic fact that we can do inward and outward transformations
on state using just cursors.

I've asked a few more experienced folks to educate me on the various
mistakes I've made and explain any failings of this abstraction or help
improve it. I'll post any updates and contributions to this thread, or you
may post your own right here.

The example is here:

https://gist.github.com/idibidiart/2b3aa1594ce707227b96

State:
(def state (atom {:parentX {
                            :childX 42
                            }
                :parentY {
                           :childY 23
                           }}))

Console log:
in-transform changes actual value of cursor: node pointed to by cursorX is
now 12 (2X value) after being set to 6
 {:parentX {:childX 12}, :parentY {:childY 23}}

out-transform changes return value: cursorY returns 2X its actual value of
23, -->  46

out-transform doesn't change actual value of cursor: node pointed to by
cursorY still shows 23 as value
 {:parentX {:childX 12}, :parentY {:childY 23}}

You can still get at cursorY's actual value via @cursorY-No-Transform  23

Just trying to understand things...

Thank you,

Marc

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