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

Using existing store with custom name ? #847

Open
chrisschaub opened this issue Sep 18, 2018 · 4 comments · May be fixed by #982
Open

Using existing store with custom name ? #847

chrisschaub opened this issue Sep 18, 2018 · 4 comments · May be fixed by #982

Comments

@chrisschaub
Copy link

I am creating datastores with createInstance. But if a user hard refreshes a page in the browser, is there a way to use that instance? It's named say "fooInstance", but how do I hookup a var to an existing instance? I see createInstance, but that seems to just blow away the datastore and start fresh. Is there a way to "useInstance" if you know it exists?

@thgreasi
Copy link
Member

Hey, createInstance tries to open an existing store (depending on the driver in use) with the provided name and only when that's not available it creates a new one, in the exact same way that config() can be used to change the store name of the default LocalForage instance. It's surprising that you mention that this doesn't work for you.
Can you provide more details on the hard refresh and the browser that this happens? Any chance the browser was in private mode?

@Dhuliang
Copy link

@thgreasi Seems that safari will create mutiple instance rather than find exist instance

@gregbown
Copy link

gregbown commented Aug 8, 2020

@thgreasi The documentation is horrible! Nowhere is it covered how the check for existing storage occurs except here, found by sifting through the issue list.. Understanding these things is key to deciding on a solution, not very inspiring or respectful of others time.

Please just add "createInstance tries to open an existing store (depending on the driver in use) with the provided name and only when that's not available it creates a new one" to the documentation It would probably take the same amount of time as answering a users question.

thgreasi added a commit to thgreasi/localForage that referenced this issue Aug 8, 2020
@thgreasi thgreasi linked a pull request Aug 8, 2020 that will close this issue
@thgreasi
Copy link
Member

thgreasi commented Aug 8, 2020

@gregbown Thanks for the hint.
Here is a PR that addresses that #982 .

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

Successfully merging a pull request may close this issue.

4 participants