0.5.0 • Published 10 months ago

@k8slens/electron-sync-store v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

electron-sync-store

Store and load JSON-serialized data to a file in electron. Supports both main and renderer. Files are written atomically.

Inspired by conf, electron-store and BaseStore of OpenLens.

Benefits:

  • async operations
  • increased performance

In race condition of multiple writes the saved file is arbitrary.

Usage:

import { ElectronSyncStore, modelUpdateEventName } from "electron-sync-store";

// Note: 'store-name' must be unique
const store = ElectronSyncStore.initialize<Model>("store-name", defaultModel, "store.json",  /* options */);

// Listen to model changes
store.events.on(modelUpdateEventName, model => {
  //
});

// After you're done with the store:
store.dispose();

Architecture

  • Main and renderer instances load initial mode from file
  • Main instances save model updates to the file and broadcast the update to renderer and other main instances
  • Renderer will broadcast model updates to main, which will save the change and broadcast the update again

License

Copyright (c) 2022 Mirantis, Inc.

Licensed under the MIT license. https://opensource.org/licenses/MIT

0.5.0

10 months ago

0.4.3

10 months ago

0.4.2

11 months ago

0.3.9

12 months ago

0.3.8

12 months ago

0.3.7

1 year ago

0.4.1

11 months ago

0.4.0

12 months ago

0.3.6

1 year ago

0.3.5

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.3.2

2 years ago

0.3.0

2 years ago

0.3.1

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.2

2 years ago