This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

ngxs-electron-storage
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

npm version

ngxs-electron-storage

This @NGXS storage plugin helps you to persist your store data in files.

It will persist any changes in your store automatically. It does check for changes and allows debouncing of file writing (see Usage).

More on how storage plugins work: Storage - ngxs.gitbooks.io

Installation

npm i ngxs-electron-storage
@NgModule({
  imports: [
    NgxsModule.forRoot(states),
    NgxsElectronStorageModule.forRoot(),
    NgxsStoragePluginModule.forRoot()
  ],
  providers: [
    {
      provide: STORAGE_ENGINE,
      useClass: ElectronStorageEngine
    }
  ]
})

Usage

You can pass a configuration object in the forRoot method.

interface ElectronStorageOptions {
  fileExtension?: string; // the file extension
  location?: string; // the location to store the files 
  debounce?: number; // you can debounce the IO process of writing the file (in milliseconds)
}
Defaults
{
  debounce0, 
  location"~",
  fileExtension"json"
}

If your given location starts with a ~ it will be replaced by the userData folder from electron: (electron.app || electron.remote.app).getPath('userData');

So you can write { location: "~/data"} to store your files in %AppData%\Roaming\your-app\data.

The plugin will ensure that the location exists once at the start and creates the directory if necessary.

ElectronStorageService

You can inject a ElectronStorageService in your components to have access to the store objects, which represent your files.

Each store object exposes a persistNotifications$ observable, which emits notifications with the store name and the serialized state. The service itself also exposes a persistNotifications$ observable, which combines all notifications of all stores.

Package Sidebar

Install

npm i ngxs-electron-storage

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

305 kB

Total Files

44

Last publish

Collaborators

  • janmalch