Skip to content

Releases: tinyplex/tinybase

v5.4.5

26 Dec 14:51
Compare
Choose a tag to compare

This release updates dependencies.

v5.4.4

18 Dec 15:23
Compare
Choose a tag to compare

This release updates dependencies.

v5.4.3

13 Dec 15:17
Compare
Choose a tag to compare

This release updates dependencies.

v5.4.2

04 Dec 22:50
Compare
Choose a tag to compare

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

04 Dec 18:34
Compare
Choose a tag to compare

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

v5.4.0

26 Nov 03:16
Compare
Choose a tag to compare

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

13 Nov 15:09
Compare
Choose a tag to compare

This release updates dependencies.

v5.3.8

03 Nov 20:50
Compare
Choose a tag to compare

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

v5.3.7

31 Oct 15:20
Compare
Choose a tag to compare

This release updates dependencies.

v5.3.6

27 Oct 14:07
Compare
Choose a tag to compare

This release updates dependencies and fixes #192