0.1.4 • Published 2 years ago

@coalesce.dev/store-worker v0.1.4

Weekly downloads
-
License
GNU GPLv3
Repository
-
Last release
2 years 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

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