Closed Aidurber closed 5 years ago
Sounds great, I would love to see a PR. Akita works great with SSR, and I can't see any reason that will not work in a non-web project. ( and if there is a reason, we'll make it disappear 😀)
Update: I have an upcoming PR that supports async storage.
I'm hoping to try this when it gets merged in... :-)
I'm submitting a...
Hi, I'm toying around with the idea of trying out Akita in a React Native app and after looking through the code, Akita has a hard dependency on
Storage
or the Storage API to be specific.When I have a bit more free time I wouldn't mind submitting a PR (unless someone else wants to tackle it), but how would you feel if I added
AsyncStorage
support? It would require creating an interface between the web Storage API and the AsyncStorage API. Judging from the persistence enhancer the only methods that are currently used are:getItem
setItem
clear
Which matches the interface of AsyncStorage, except Async storage is - you guessed it - async. The enhancement would require a similar approach to what redux-persist, if you're in the browser (default), then create an async adapter for the web based version. Which is just wrapping them in promises.
The file naming convention does the heavy lifting I believe:
React native will prefer a
*.native
file I believe (but don't quote me on that).Or even better would be to allow a custom storage solution where people can provide different storage enhancers as long as it matches the new custom storage API, similar to what redux-persist does. That will allow for things like SQLite storage or doing some simple obfuscation if they're into that kind of thing.
Firstly, what are your thoughts on this?
Do you foresee any other issues using Akita in a non-web project? Any hidden caveats or anything?
Thanks! ❤️