Closed aksonov closed 8 years ago
Does it work with react native?
I think it should. I'm not exactly sure what would prevent it from working with RN.
Is it possible to load/persist store to RN AsyncLocalStorage?
Yep, if you look at the source code for my localstorage adapter that I include with the library, it's extremely simple.
// @flow
function read(source: string) {
const data = localStorage.getItem(source)
if (data) {
return JSON.parse(data)
}
return {}
}
function write(dest: string, store: Object) {
return localStorage.setItem(dest, JSON.stringify(store.contents()))
}
export default { read, write }
All you would have to do is create your own read and write functions for AsyncLocalStorage. Then you would use it like you would anything else:
import asyncLocalStorage from './your-implementation-of-it'
// Read
const store = mobxstore(asyncLocalStorage.read('whateveryouwant'))
// Write
store.schedule([asyncLocalStorage.write, 'whateveryouwant', store])
Make sense?
Thanks!
Let me know if you have any other questions.
Does it work with react native? Is it possible to load/persist store to RN AsyncLocalStorage?