question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Persistence] React Native & Model Layer

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:33 (29 by maintainers)

github_iconTop GitHub Comments

1reaction
sahrenscommented, Oct 14, 2015

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.

0reactions
cbfrancacommented, Dec 29, 2017

@yelled3 , how did you solve your situation ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Persisting data in React Native - Pusher
This tutorial takes a look at four different ways to handle persisting data in React Native. You will be introduced to AsyncStorage, Realm, ......
Read more >
Frontend Handbook | React Native / Data persistence - Infinum
Most popular methods for data persistence in React Native are: AsyncStorage; Realm; SQLite; Firebase; RN local MongoDB. AsyncStorage.
Read more >
How To Use Redux Persist in React Native with Asyncstorage
The Redux Persist library provides an easy way to save a Redux store in the local storage of React Native apps. In this...
Read more >
What are the best ways to persist data with React Native?
Out of the box, the only way to persist data is AsyncStorage. ... React Native is just a view layer, it does not...
Read more >
Optimize React apps using a multi-layered structure
How multi-layered structures optimize React applications ... and define a top-level index.js file containing your store and persist logic.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found