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

Question: Can stores be using across multiple files? #169

Closed
sinjs opened this issue Feb 26, 2021 · 1 comment
Closed

Question: Can stores be using across multiple files? #169

sinjs opened this issue Feb 26, 2021 · 1 comment

Comments

@sinjs
Copy link

sinjs commented Feb 26, 2021

I'm asking if I can use stores across multiple files like this:

one.js

const Store = require('electron-store');
const store = new Store();

store.set('unicorn', '🦄');

two.js

const Store = require('electron-store');
const store = new Store();

var unicorn = store.get('unicorn');
console.log(unicorn); // => 🦄

or will it create two seperate stores?

@sindresorhus
Copy link
Owner

It's possible if both the constructors receive the exact same options, but it's not recommended. Instead, create a store.js file, setup the store there and import that file into one.js and two.js.

#15

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

No branches or pull requests

2 participants