Raynos / mercury

A truly modular frontend framework
http://raynos.github.io/mercury/
MIT License
2.82k stars 143 forks source link

Redux + mercury example? #194

Closed bcomnes closed 8 years ago

bcomnes commented 8 years ago

Has anyone put together an example of using mercury with redux?

jxson commented 8 years ago

Not as far as I know but there are some examples using immutable.js and backbone if you need the reference: https://github.com/Raynos/mercury/tree/master/examples/unidirectional

bcomnes commented 8 years ago

I guess I'll start there. Unfortunately the redux bindings for react are a bit beyond trivial: https://github.com/rackt/react-redux/blob/master/src/components/connect.js I'll share back if I find out anything interesting. Should I close the issue for now?

kumavis commented 8 years ago

@bcomnes i've been playing with redux+react+hyperscript recently and its pretty nice. may be what you're looking for. https://github.com/kumavis/reddit-images

bcomnes commented 8 years ago

Thanks @kumavis! I'll look through it for some hints. I'm curious what using mercury for the view layer and redux for the app state would look like, but I can't find any examples, but I'm thinking I'll have to fully understand where the two projects overlap first.

ahdinosaur commented 8 years ago

@bcomnes i've had fun with redux + vdux + virtual-dom. for examples, see conway-redux-vdom and linked-data-browser.

kumavis commented 8 years ago

mercury for the view layer and redux for the app state

mercury is mostly observ for the observable state graph and virtual-hyperscript for the view, w/o any opinionated component format.

bcomnes commented 8 years ago

I'm going to close this for now. I think I need to take some time to sit with both tools in order to understand the overlap some more. I'll revisit in the future if I think its worth writing something up. If someone else feels like its worth it, feel free!

crabmusket commented 8 years ago

For what it's worth, I've started to think of Mercury as a really good viewmodel. If your application is essentially a UI, then the viewmodel might suffice, and there's not much point adding another state layer on top of it. However, in the project I was working on, we had a more complicated state that was shared peer-to-peer using crdt. It was easiest to treat the replicated datastore as the model, then render any changes in it to Mercury's viewmodel, then render from there to the DOM in the usual Mercury fashion.

Raynos commented 8 years ago

I agree with @eightyeight

I think mercury state representation makes a good view / viewmodel.

You want to model and persist the raw data somewhere else; whether thats crdt or some other set of classes.

ghost commented 7 years ago

@raynos so if you are interacting with an API you'd recommend storing the resultant raw data in redux?