Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Contents of a database in memory? #117

Closed
briansunter opened this issue May 18, 2016 · 4 comments
Closed

[Question] Contents of a database in memory? #117

briansunter opened this issue May 18, 2016 · 4 comments

Comments

@briansunter
Copy link

briansunter commented May 18, 2016

No description provided.

@Ben-G
Copy link
Member

Ben-G commented May 19, 2016

Hey @brsunter!

Thanks for the question. This has actually come up before (and should eventually make it into the readme). I've discussed a solution in #110. Can you check it out and see if it answers your question?

@briansunter
Copy link
Author

Hey @Ben-G thanks for the response. I had a look at the thread and It looked like most of the discussion was about ways to keep the ReSwift state in sync with the DB state. However, my concern is having the entire contents of the database in memory when I only need certain parts of it at a given time. I was wondering if there were any best practices around having a database hold information that is not "mirrored" in the app state. I was thinking something along the lines of sending an action that loads subsets of information into the app state, but this breaks the idea that the app state is the single source of truth.
Sorry if this is a weird question, I was just wondering if anyone had given this any thought.

@ianterrell
Copy link

Hi @brsunter,

I'm reading all the open issues and came across this one. I think that @Ben-G's comments and the discussion on #110 do address this issue.

I was wondering if there were any best practices around having a database hold information that is not "mirrored" in the app state. I was thinking something along the lines of sending an action that loads subsets of information into the app state...

I think that same idea is what's captured on #110:

Treat the db similar to a webservice; as a failable outside resource. This would mean you would use ActionCreator or a similar concept to perform the db update before you update the state via reducers.

That would just mean that you'd query the database in the same manner that you'd query a webservice: perhaps in an ActionCreator, or in middleware (a la redux-saga), or in an extended store (a la redux-loop). Issue #64 has a great summary of options and some links to possible implementation ideas.

... but this breaks the idea that the app state is the single source of truth.

Personal opinion only, but I have been viewing app state as relating primarily to the state required to set up and manage the UI and user interaction. I do not view a database as part of the app state any more than I view a remote web service as part of the app state: they both contain information that my app may optionally use in its UI.

Hope this helps!

Thanks,
Ian

@briansunter
Copy link
Author

Hey Ian,
Thanks for the response. Still wrapping my head around the unidirectional model a little bit and your comment about only keeping the minimum of what's needed for the UI at a given time cleared things up for me. Getting something like redux loops looks like an amazing way to handle side effects btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants