Yeah both in and out transforms are useful in this case. Out transforms for 
what you stated and in transforms for cases where you might want to transform 
data from the server to store into a particular data structure within the atom.

We keep app state in one place but have not implemented the Flux pattern yet 
and thats because things are really simple when your app is concerned with 
implementing a single feature and you stitch such micro apps together via 
server side routes and common header and footer. We're not building a complex 
app in one composed view and each view is extremely simple. 

The cursor transforms are something I'm playing with atm to try out ideas like 
automatic in and out transforms and multi-focus lenses but i think multi-focus 
lenses would basically implement a hidden state structure and i think that 
would be a bad idea. 

I have to experiment with Reactions! Thanks for reminding me that they're part 
of Reagent! I think they're part of how cursors are implemented, but havent 
looked closely yet.

Thanks!



Sent from my iPhone

> On Apr 29, 2015, at 3:59 PM, [email protected] wrote:
> 
> If you are not interested in in-transofrmation and only in 
> out-transformation(have different views on state suitable for components not 
> for keeping real state) you can use reaction which should be part of reagent. 
> As for in-transformation if you are using something like flux architecture 
> then you have separate responsibility to rise event that you want to change 
> state and having entity(some function) responsible to change state acording 
> to event so it's easy to incorporate these in-transformation in this entity.
> 
> Look at this https://github.com/Day8/re-frame and for reactions 
> https://github.com/Day8/re-frame#how-flow-happens-in-reagent
> 
> Hope this will help
> maty
> 
>> On Tuesday, April 28, 2015 at 4:17:32 AM UTC+2, marc fawzi wrote:
>> 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
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Reagent-Project" 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/reagent-project.
> For more options, visit https://groups.google.com/d/optout.

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