3 ms·
What I need is something like this that abstracts away where data is coming from (i.e. facade pattern). This would help make implementing offline capability sea
by mattdeboard 12y ago
What I need is something like this that abstracts away where data is coming from (i.e. facade pattern). This would help make implementing offline capability seamless, and a discrete concern from the UI.
- j_s 12y agoSounds like a legit feature request to add to the issues there!
- mattdeboard 12y agoSeems kind of out-of-scope for Cortex. But the notion in general is something I yearn for mightily.
- binarymax 12y agoIndeed. I spent a bunch of time looking for something like that which already exists, but couldn't find anything and have resigned to building it myself. When it gets to a better state I'll be releasing it. Probably in a week or so.
- mattdeboard 12y agoCan you contact me via email? In my profile.
- dustingetz 12y agoI would like to see this as well.
- findjashua 12y agolooking forward!
- nwienert 12y ago+1 on being interested... I'm beginning the same journey here: https://github.com/natew/testreactor https://github.com/natew/testreactor
- sprobertson 12y agoI'm new to the React world but this sounds a bit like what Flux (http://facebook.github.io/react/docs/flux-overview.html http://facebook.github.io/react/docs/flux-overview.html) is trying to acheive. Does anyone know how these libraries (either cursor or cortex) could tie into that architecture?
- mattdeboard 12y agoI'm not really concerned about React-specific implementation, but rather a data structure that serves as a facade over the storage layer (either a remote server or the storage systems made available to the browser). This way the UI (e.g. React components and other view-like things) just talks to this facade and doesn't have to know anything about the network, its availability, or browser-specific storage options. Mozilla's localForage is a good tool specifically for abstracting away the client-side storage mechanism from the UI logic. Aside from that I have looked at Flux and its stores would be the place where you would implement such a facade.
- lmb 12y agoWell, Fb gave a presentation that said interaction with their web utils (so storage if you want to call it that) actually happens in the action itself, with pending, success and failure "actions" (events really) being dispatches to the stores. Not sure what that means for your facade, but it's confusing the hell out of me. What is the store supposed to do? Just hold onto the state, period?
- dustingetz 12y agonot sure if i am following you, but in my apps, the data is always in React state. Whether it came from network or from localstorage is irrelevant. There is some code somewhere that loads data into React state from whatever source. All react is doing is rendering views as a fn of state.
- napoleond 12y agoI've used PouchDB this way in the past, and it worked well for seamlessly enabling offline use/hiding network concerns from the view layer, but it's probably a lot "thicker" than what you have in mind (and isn't completely browser-proof, and requires the server storage to look like a CouchDB). It's interesting to imagine what the lighter facade you're describing might look like. I guess you'd want the controllers/views to get a key-value style interface, and you'd want the facade to connect with one or more local storage options, and some sort of logic to manage triage between local and remote storage, and syncing between the two, and a well-defined API for connecting the remote storage. Hmmm...