0.1.4 • Published 1 year ago

@coalesce.dev/store-worker v0.1.4

Weekly downloads
-
License
GNU GPLv3
Repository
-
Last release
1 year ago

Shared Store - Worker

@coalesce.dev/store-worker

This package provides a library used to create the worker component of a shared store.

Usage

Create a file to be used as the entry point of the worker. For example, here is a file that sets up a store using the HTTP plugin:

import { SharedStore } from '@coalesce.dev/store-worker';
import { schema } from '../schema';
import { HttpPlugin } from '@coalesce.dev/store-plugins-http';

const store = new SharedStore('exampleStoreId', schema, {
  ...HttpPlugin,
});

This worker can then be loaded using the @coalesce.dev/store-client package:

import { SharedStoreClient } from '@coalesce.dev/store-client';
import { schema } from '../schema';

export const storeClient = new SharedStoreClient(
  () =>
    new SharedWorker(new URL('../worker', import.meta.url), {
      name: 'example-worker',
    }),
  schema
);

The state of the worker will periodically be persisted in an IndexedDB database shortly after any mutations. When the worker is restarted, it will load this previous state.

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago