Closed leo closed 7 years ago
that's what I think too... I do not want to store config, but some cached data
It works great as a persistent store!
But is that the way it's meant to be used? Doesn't it write your changes to disk everytime you set something, and won't it read the file back in every time you get something? That is not very efficient for a store right? Or shouldn't we worry too much about that? Something with premature-optimization being evil 😈 ?
Upside is of course that it gives you persistence even when your app is abruptly terminated 😄
@leo Done at last. Thanks for the idea.
@teameh It shouldn't be a problem for most use-cases. Fs isn't that slow. And synchronous fs is faster than async, because async has overhead with event-loop. Async would indeed be a premature-optimization. If you encounter the need to use it in a hot code path, you could always set everything at once with .set(object)
.
Wonderful new name! ❤️
Would this have any impact on projects that used electron-config
. Should any migration steps be followed? Because npm still has a package named electon-config
.
Thanks.
IMHO, this package can be used for either the config or just for saving/caching data (like we're doing it in Now Desktop). Because of this, I recommend renaming it.
My suggestion is "electron-store" (the package name is available on npm).