sindresorhus / electron-store

Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc
MIT License
4.6k stars 150 forks source link

Not required in electron apps anymore? #174

Open anujdatar opened 3 years ago

anujdatar commented 3 years ago

As of electron 12, this module may not be needed anymore. As far as my tests goes, just the basic conf module works just fine. electron.remote deprecation was fixed with ipc, but may be completely unnecessary. conf now gets the correct parentDir values when used with electron directly, unlike earlier versions.

I tested this with Electron on linux, using basic npm start, as an AppImage, and deb and snap packages. They all work fine with conf.

I have not tested with electron 11, this may be true for that as well.

ivancuric commented 3 years ago

I am just working on how to persist app data inside an electron app, and just came across both these packages and this issue. How is electron-store different from conf?

On conf's homepage it says:

It does not support multiple processes writing to the same store.\ I initially made this tool to let command-line tools persist some data.

If you need this for Electron, check out electron-store instead.

but as far as I can see, the API is exactly the same, including both of them having the watch API.

sindresorhus commented 3 years ago

Some benefits of using electron-store store over conf:

sindresorhus commented 3 years ago

@ivancuric Multiple Electron processes and multiple Node.js processes are not the same. Electron does have multiple processes, but only one process, the main process, can write to the store directly. For Node.js, however, multiple independent processes could write to the store.

ivancuric commented 3 years ago

only one process, the main process can write to the store directly

Would it be a good idea to expose electron-store directly in the renderer process via preload?

I am already using a global state management library, with some stores holding persistent/serializable data. It seems like a good idea to perhaps use electron-store as a middleware for that one, so I might as well skip the IPC messaging part.