Skip to content

Releases: tinyplex/tinybase

v5.4.6

Choose a tag to compare

@jamesgpearce jamesgpearce released this 06 Jan 15:01

This release updates dependencies.

v5.4.5

Choose a tag to compare

@jamesgpearce jamesgpearce released this 26 Dec 14:51

This release updates dependencies.

v5.4.4

Choose a tag to compare

@jamesgpearce jamesgpearce released this 18 Dec 15:23

This release updates dependencies.

v5.4.3

Choose a tag to compare

@jamesgpearce jamesgpearce released this 13 Dec 15:17

This release updates dependencies.

v5.4.2

Choose a tag to compare

@jamesgpearce jamesgpearce released this 04 Dec 22:50

This release updates the setContent, setDefaultContent, load, and startAutoLoad methods of the Store, MergeableStore, and Persister interfaces respectively. They all take a content parameter, which can now be either a content array (as before) or now a function that returns the same content array.

v5.4.1

Choose a tag to compare

@jamesgpearce jamesgpearce released this 04 Dec 18:34

This release updates dependencies and adds a convenient useStores React hook.

v5.4.0

Choose a tag to compare

@jamesgpearce jamesgpearce released this 26 Nov 03:16

Durable Objects synchronization

This release contains a new WebSocket synchronization server that runs on Cloudflare as a Durable Object.

image

It's in the new synchronizer-ws-server-durable-object module, and you use it by extending the WsServerDurableObject class. Use the getWsServerDurableObjectFetch function for conveniently binding your Cloudflare Worker to your Durable Object:

import {
  WsServerDurableObject,
  getWsServerDurableObjectFetch,
} from 'tinybase/synchronizers/synchronizer-ws-server-durable-object';

export class MyDurableObject extends WsServerDurableObject {}

export default {fetch: getWsServerDurableObjectFetch('MyDurableObjects')};

For the above code to work, you'll need to have a Wrangler configuration that connects the MyDurableObject class to the MyDurableObjects namespace. In other words, you'll have something like this in your wrangler.toml file:

[[durable_objects.bindings]]
name = "MyDurableObjects"
class_name = "MyDurableObject"

With this you can now easily connect and synchronize clients that are using the WsSynchronizer synchronizer.

Durable Objects Persistence

But wait! There's more. Durable Objects also provide a storage mechanism, and sometimes you want TinyBase data to also be stored on the server (in case all the current clients disconnect and a new one joins, for example). So this release of TinyBase also includes a dedicated persister, the DurableObjectStoragePersister, that also synchronizes the data to the Durable Object storage layer.

You create it with the createDurableObjectStoragePersister function, and hook it into the Durable Object by returning it from the createPersister method of your WsServerDurableObject:

export class MyDurableObject extends WsServerDurableObject {
  createPersister() {
    return createDurableObjectStoragePersister(
      createMergeableStore(),
      this.ctx.storage,
    );
  }
}

You can get started quickly with this architecture using the new Vite template that accompanies this release.

Server Reference Implementation

Unrelated to Durable Objects, this release also includes the new synchronizer-ws-server-simple module that contains a simple server implementation called WsServerSimple. Without the complications of listeners, persistence, or statistics, this is more suitable to be used as a reference implementation for other server environments.

Architectural Guide

To go with this release, we have added new documentation on ways in which you can use TinyBase in an app architecture. Check it out in the new Architectural Options guide.

We've also started a new section of documentation for describing integrations, of which the Cloudflare Durable Objects guide, of course, is the first new entry!

v5.3.9

Choose a tag to compare

@jamesgpearce jamesgpearce released this 13 Nov 15:09

This release updates dependencies.

v5.3.8

Choose a tag to compare

@jamesgpearce jamesgpearce released this 03 Nov 20:50

This release updates dependencies, fixes #194, and allows WsServer instances to handle silent errors.

v5.3.7

Choose a tag to compare

@jamesgpearce jamesgpearce released this 31 Oct 15:20

This release updates dependencies.