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

2.0 #35

Closed
8 tasks
rt2zz opened this issue Nov 1, 2015 · 3 comments
Closed
8 tasks

2.0 #35

rt2zz opened this issue Nov 1, 2015 · 3 comments

Comments

@rt2zz
Copy link
Owner

rt2zz commented Nov 1, 2015

  • move serialize/deserialize responsibility into storage engine
    • how to handle AsyncStorage?
  • consider defaulting to localForage
  • single rehydrate action
  • evaluate what top level immutable support looks like
  • consider removal of rehydrateAction and completeAction
  • should persistor.rehydrate accept "serialized" payload or should deserialization be a responsbility of the caller?
  • buffer actions:
    • can we avoid dispatching REHYDRATE_COMPLETE when skipRestore: true
    • how should buffer actions work if there are multiple persistors
  • do we need a coordinated factory so that autoRehydrate and persistStore can share state/config?
    • i.e. let {persistStore, autoRehydrate} = createPersistScheme(config)
@84564221
Copy link

The persistStore configuration API should be removed, since it is a pure functional programming anti-pattern.

You don't use configuration to construct your store, you use composition. In that way, you aren't limited to solely the mechanisms thought out ahead of time.

@rt2zz
Copy link
Owner Author

rt2zz commented Dec 23, 2015

@askmatey I have thought about this, and this is more in line with e.g. how redux-localstorage works

The reasoning for the configuration based approach is that it is simple. IMO the alternative is actually not inherently more "functional", it just moves configuration from being an object to being implicit in what you choose to require. It still suffers from limitations of preconceived design.

That said I am entirely open to a more functional pattern, and any api suggestions would be appreciated.

@rt2zz
Copy link
Owner Author

rt2zz commented Feb 10, 2016

Just pushed a first cut at 2.0 to master. Key changes:

Only one REHYDRATE action which now contains the entire stored state tree. No REHYDRATE_COMPLETE action is needed since, REHYDRATE implicitly means rehydration is complete.

All api's are updated accordingly so e.g. persistor.rehydrate now looks like this: persistor.rehydrate(serialState).

I will continue to mess with the api over the next few days. In particular I want to spend some time thinking over the way transforms and serialization happen.

As far as functional composition, I am open to suggestions for how to improve this. I suspect we will always need a configuration object to keep certain basic use cases dead simple e.g. setting the storage engine. That said I suspect there may be some way to expose a functional primitive around transforms and serialization.

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

2 participants