[Persistence] React Native & Model Layer
See original GitHub issueI was working on my RN iOS app and started thinking on how to work with Models;
Now, I realise that React (& RN) are the View in MVC and doesn’t deal with the Model layer. More over, I know that this issue is somewhat related to issues Relay is trying to solve.
That being said, I want add persistence to my flux RN app.
Let’s also assume the AsyncStorage
(http://facebook.github.io/react-native/docs/asyncstorage.html) is too simplistic for my needs. (I’m also unsure how performant it is on large datasets)
an obvious solution would be to use CoreData or Realm and defining my models in Native objC/Swift.
now I’m faced with 2 options:
- redefine the same models in js in my RN app and serialize then through the bridge - allowing me to have more model logic in the RN app and the keeping the Native minimal.
- keep only the objC/Swift models and have the RN app work with raw JSONs - keeping the model logic in the Native side.
I was wondering if there’s another option I’m missing here? and also which of the above options would you generally recommend?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:33 (29 by maintainers)
Here’s our internal module with the internal stuff stripped out:
https://gist.github.com/sahrens/ae3ad0889c608ecd51aa
It won’t compile of course, but should get you started.
@yelled3 , how did you solve your situation ?