diff --git a/docs/guides/releases/article.html b/docs/guides/releases/article.html index 9a8d005aeb..f956342f69 100644 --- a/docs/guides/releases/article.html +++ b/docs/guides/releases/article.html @@ -7,7 +7,7 @@ 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 something like this in your wrangler.toml
file:
[[durable_objects.bindings]]
+
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 using the WsSynchronizer
synchronizer. This implementation does not currently store the data between clients, but will soon!
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.
This release is focussed on a few API improvements and quality-of-life changes. These include:
Thanks to contributor Muhammad Muhajir for ensuring that TinyBase runs in server-side rendering environments!
persisters
module...All Persister
objects now expose information about whether they are loading or saving. To access this Status
, use:
getStatus
method, which will return 0 when it is idle, 1 when it is loading, and 2 when it is saving.addStatusListener
method, which lets you add a StatusListener
function and which is called whenever the status changes.These make it possible to track background load and save activities, so that, for example, you can show a status-bar spinner of asynchronous persistence activity.
synchronizers
module...Synchronizers are a sub-class of Persister
, so all Synchronizer
objects now also have:
getStatus
method, which will return 0 when it is idle, 1 when it is 'loading' (ie inbound syncing), and 2 when it is 'saving' (ie outbound syncing).addStatusListener
method, which lets you add a StatusListener
function and which is called whenever the status changes.ui-react
module...There are corresponding hooks so that you can build these status changes into a React UI easily:
usePersisterStatus
hook, which will return the status for an explicitly provided, or context-derived Persister
.usePersisterStatusListener
hook, which lets you add your own StatusListener
function to a Persister
.usePersister
hook, which lets you get direct access to a Persister
from within your UI.And correspondingly for Synchronizers:
useSynchronizerStatus
hook, which will return the status for an explicitly provided, or context-derived Synchronizer
.useSynchronizerStatusListener
hook, which lets you add your own StatusListener
function to a Synchronizer
.useSynchronizer
hook, which lets you get direct access to a Synchronizer
from within your UI.In addition, this module also now includes hooks for injecting objects into the Provider context scope imperatively, much like the existing useProvideStore
hook:
useProvideMetrics
hook, which lets you imperatively register Metrics
objects.useProvideIndexes
hook, which lets you register Indexes
objects.useProvideRelationships
hook, which lets you register Relationships
objects.useProvideQueries
hook, which lets you register Queries
objects.useProvideCheckpoints
hook, which lets you register Checkpoints
objects.useProvidePersister
hook, which lets you register Persister
objects.useProvideSynchronizer
hook, which lets you register Synchronizer
objects.All of these new methods have extensive documentation, each with examples to show how to use them.
Please provide feedback on this new release on GitHub!
This release introduces new Persisters for... PostgreSQL! TinyBase now has two new Persister
modules:
persister-postgres
module provides the PostgresPersister
, which uses the excellent postgres
module to bind to regular PostgreSQL databases, generally on a server.persister-pglite
module provides the PglitePersister
, which uses the new and exciting pglite
module for running PostgreSQL... in a browser!Conceptually, things behave in the same way as they do for the various SQLite persisters. Simply use the createPostgresPersister
function (or the similar createPglitePersister
function) to persist your TinyBase data:
import postgres from 'postgres';
diff --git a/docs/guides/releases/index.html b/docs/guides/releases/index.html
index 92e81b5d27..bf9124bf62 100644
--- a/docs/guides/releases/index.html
+++ b/docs/guides/releases/index.html
@@ -7,7 +7,7 @@
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 something like this in your wrangler.toml
file:
[[durable_objects.bindings]]
+
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 using the WsSynchronizer
synchronizer. This implementation does not currently store the data between clients, but will soon!
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.
This release is focussed on a few API improvements and quality-of-life changes. These include:
Thanks to contributor Muhammad Muhajir for ensuring that TinyBase runs in server-side rendering environments!
persisters
module...All Persister
objects now expose information about whether they are loading or saving. To access this Status
, use:
getStatus
method, which will return 0 when it is idle, 1 when it is loading, and 2 when it is saving.addStatusListener
method, which lets you add a StatusListener
function and which is called whenever the status changes.These make it possible to track background load and save activities, so that, for example, you can show a status-bar spinner of asynchronous persistence activity.
synchronizers
module...Synchronizers are a sub-class of Persister
, so all Synchronizer
objects now also have:
getStatus
method, which will return 0 when it is idle, 1 when it is 'loading' (ie inbound syncing), and 2 when it is 'saving' (ie outbound syncing).addStatusListener
method, which lets you add a StatusListener
function and which is called whenever the status changes.ui-react
module...There are corresponding hooks so that you can build these status changes into a React UI easily:
usePersisterStatus
hook, which will return the status for an explicitly provided, or context-derived Persister
.usePersisterStatusListener
hook, which lets you add your own StatusListener
function to a Persister
.usePersister
hook, which lets you get direct access to a Persister
from within your UI.And correspondingly for Synchronizers:
useSynchronizerStatus
hook, which will return the status for an explicitly provided, or context-derived Synchronizer
.useSynchronizerStatusListener
hook, which lets you add your own StatusListener
function to a Synchronizer
.useSynchronizer
hook, which lets you get direct access to a Synchronizer
from within your UI.In addition, this module also now includes hooks for injecting objects into the Provider context scope imperatively, much like the existing useProvideStore
hook:
useProvideMetrics
hook, which lets you imperatively register Metrics
objects.useProvideIndexes
hook, which lets you register Indexes
objects.useProvideRelationships
hook, which lets you register Relationships
objects.useProvideQueries
hook, which lets you register Queries
objects.useProvideCheckpoints
hook, which lets you register Checkpoints
objects.useProvidePersister
hook, which lets you register Persister
objects.useProvideSynchronizer
hook, which lets you register Synchronizer
objects.All of these new methods have extensive documentation, each with examples to show how to use them.
Please provide feedback on this new release on GitHub!
This release introduces new Persisters for... PostgreSQL! TinyBase now has two new Persister
modules:
persister-postgres
module provides the PostgresPersister
, which uses the excellent postgres
module to bind to regular PostgreSQL databases, generally on a server.persister-pglite
module provides the PglitePersister
, which uses the new and exciting pglite
module for running PostgreSQL... in a browser!Conceptually, things behave in the same way as they do for the various SQLite persisters. Simply use the createPostgresPersister
function (or the similar createPglitePersister
function) to persist your TinyBase data:
import postgres from 'postgres';
diff --git a/releases.md b/releases.md
index 31fe4e7e20..122da4bee3 100644
--- a/releases.md
+++ b/releases.md
@@ -12,7 +12,7 @@ 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 something like this in your wrangler.toml
file:
+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:
```toml
[[durable_objects.bindings]]
diff --git a/site/guides/14_releases.md b/site/guides/14_releases.md
index 89c1db54d5..3a957f2f18 100644
--- a/site/guides/14_releases.md
+++ b/site/guides/14_releases.md
@@ -25,7 +25,7 @@ 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 something like this in your `wrangler.toml` file:
+other words, you'll have something like this in your `wrangler.toml` file:
```toml
[[durable_objects.bindings]]