-
Notifications
You must be signed in to change notification settings - Fork 11
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
how to use non-default localforage instance? #31
Comments
I don't think localForage-backbone supports multiple instances yet. If you just want to change the db name per user you should be able to do that with the configuration. Multiple instances are more useful when needing to deal with different sets of data at the same time. If you don't have multiple users signed in at once it might be overkill.
|
Makes sense, I will try that. However, is it possible to switch stores through localforage.config or I need to close the existing/open store first? I don't know how to close and reopen a store once driver has been set. |
Once it has been set you can’t change the store, so if you want to change the store or database name with a page refresh, you WILL want to try multiple instances.
That will require a patch to localforage-backbone, I think.
|
I tried something that seems to work without breaking existing code. Here are the relevant, small changes I made (on top of many others).
Then, I changed all locarforage instances to this.localforageInstance (inside save, update, find etc methods ). Before returning (at the bottom):
So Backbone.localforage still uses the default localforage variable and for separate instances, I do:
Can you think of any issues? |
@siddo420 I've not played with multiple instance of localforage instance but I've already managed to play with different stores. I mean I was able to switch between localstorage, websql and indexeddb depending on what the device supports. This was only made for a testing. |
how do I use separate localforage instances (instead of localforage)?
I am thinking of creating different instances per user (makes sense on installed apps).
Ref: https://github.com/mozilla/localForage#multiple-instances
The text was updated successfully, but these errors were encountered: