-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Accessing store from renderer #109
Comments
#15 (And yes, I need to get that documented in the readme) |
@sindresorhus I would recommend documenting something like this for accessing store values from the renderer: ipcMain.on('requestStoreValue', (event, key) => {
event.sender.send('replyStoreValue', key, store.get(key));
}); |
Agreed. Especially important as Electron plans to deprecate the |
@sindresorhus would you like me to try to throw together a PR? |
@rwwagner90 That would be great. Would be best to show usage with the |
@sindresorhus I opened a PR. Please let me know if you would like any changes to the content! |
@sindresorhus I just found out I can set in Main process and directly get in renderer process, but why since you mentioned it's not a singleton. // mainProcess.js
import Store from 'electron-store';
const store = new Store();
store.set('foo', 'bar'); // renderer.js
import Store from 'electron-store';
const store = new Store();
store.get('foo');
//=> 'bar' |
I've been looking through issues about how to use the store in the renderer, and most issues say something like
just use it the same as you would in main
, but this is confusing to me. It appears the store is not a singleton, so if you set it up in main, there is no way to access the same store in the renderer, correct?The text was updated successfully, but these errors were encountered: