sindresorhus / electron-store

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

Enhancement Request #248

Closed wmelton closed 1 year ago

wmelton commented 1 year ago

Curious what the appetite is to add helper functions that alias existing functions to match the official Web Storage API?

This feels kind of clunky if you're running a web app and electron app on the same code base:

const removeItem = async (key: string): Promise<void> => {
  if (electron) {
    return electronStorage.delete(key)
  }
  return windowStorage.removeItem(key)
}
sindresorhus commented 1 year ago

It doesn't really make sense to me. The API's are very different even though they have three similar methods. I also don't think it's a very common use-case. This package has existed for years and no one else has requested this.

It should be simple to subclass the Store class and add such methods yourself and then you can just import your subclass instead of electron-store where you need it.

wmelton commented 1 year ago

We built our own wrapper for this, but I am surprised that we feel adopting consistent function names for browser APIs that have existed a lot longer than Electron would fail to make sense. Difficult to think teams are building and running two disparate code bases for web app vs desktop app if they're using Electron.

Anyway - the library is still useful. I was just advocating for a more consistent developer experience. Appreciate your contribution to the open source community all the same.