-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
localForage support? #3
Comments
I think you can just pass storageEngine option to the plugin, so currently this plugin you can adjust to your needs, imho |
So i'm think this should work: import { getStore } from 'kea'
import createHistory from 'history/createBrowserHistory'
import { routerReducer, routerMiddleware } from 'react-router-redux'
import sagaPlugin from 'kea-saga/es'
import localStoragePlugin from 'kea-localstorage';
// import localForagePlugin from './lib/keaLocalForage'
export const history = createHistory()
export const store = getStore({
middleware: [
routerMiddleware(history)
],
reducers: {
router: routerReducer,
},
plugins: [
sagaPlugin,
localStoragePlugin({
storageEngine: localforage.createInstance({ name: 'appState' }) // or other store instance
}),
]
}) |
I think maybe it need more clear way to set and get fields from storage |
I'll try to fix this on weekend |
@sanchezweezer was you able to get it working? I'm close but having issues due to localforage being async. I can get it kind of working but it won't read from cache if the page is refreshed. |
While this plugin works great as is, localStorage is a bit problematic with the size limits and so on. I'm not worried that my app state will ever exceed 5MB, but I'd like to store it elsewhere anyway, partially because I'm already using localForage for other things, and would want to save localForage for something more critical. Or something.
Since localForage and localStorage have similar APIs (w/ the exception of localForage being async), I tried it myself with the following fork, but it obviously didn't work, something else is clearly happening behind the scenes, but I've no idea what.
appState is simply
export const appState = localforage.createInstance({ name: 'appState' })
.This is how I've created the store:
So, any plans for localForage? 🤔
The text was updated successfully, but these errors were encountered: