Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const conn = new DbConnection.builder()
using SpacetimeDB;

var conn = DbConnection.Builder()
.WithUri(new Uri("https://maincloud.spacetimedb.com"))
.WithUri("https://maincloud.spacetimedb.com")
.WithDatabaseName("my_database")
.Build();
```
Expand Down Expand Up @@ -90,7 +90,7 @@ const conn = new DbConnection.builder()

```csharp
var conn = DbConnection.Builder()
.WithUri(new Uri("https://maincloud.spacetimedb.com"))
.WithUri("https://maincloud.spacetimedb.com")
.WithDatabaseName("my_database")
.Build();
```
Expand Down Expand Up @@ -137,7 +137,7 @@ const conn = new DbConnection.builder()

```csharp
var conn = DbConnection.Builder()
.WithUri(new Uri("https://maincloud.spacetimedb.com"))
.WithUri("https://maincloud.spacetimedb.com")
.WithDatabaseName("my_database")
.WithToken("your_auth_token_here")
.Build();
Expand Down Expand Up @@ -256,7 +256,7 @@ const conn = DbConnection.builder()

```csharp
var conn = DbConnection.Builder()
.WithUri(new Uri("https://maincloud.spacetimedb.com"))
.WithUri("https://maincloud.spacetimedb.com")
.WithDatabaseName("my_database")
.OnConnect((conn, identity, token) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Before diving into the reference, you may want to review:
| [`EventContext` type](#type-eventcontext) | Implements [`IDbContext`](#interface-idbcontext) for [row callbacks](#callback-oninsert). |
| [`ReducerEventContext` type](#type-reducereventcontext) | Implements [`IDbContext`](#interface-idbcontext) for [reducer callbacks](#observe-and-invoke-reducers). |
| [`SubscriptionEventContext` type](#type-subscriptioneventcontext) | Implements [`IDbContext`](#interface-idbcontext) for [subscription callbacks](#subscribe-to-queries). |
| [`ErrorContext` type](#type-errorcontext) | Implements [`IDbContext`](#interface-idbcontext) for error-related callbacks. |
| [`ErrorContext` type](#type-errorcontext) | Implements [`IDbContext`](#interface-idbcontext) for subscription error callbacks. |
| [Query Builder API](#query-builder-api) | Type-safe query builder for typed subscription queries. |
| [Access the client cache](#access-the-client-cache) | Access to your local view of the database. |
| [Observe and invoke reducers](#observe-and-invoke-reducers) | Send requests to the database to run reducers, and register callbacks to run when notified of reducers. |
Expand Down Expand Up @@ -115,7 +115,7 @@ Construct a `DbConnection` by calling `DbConnection.Builder()`, chaining configu
```csharp
class DbConnectionBuilder<DbConnection>
{
public DbConnectionBuilder<DbConnection> WithUri(Uri uri);
public DbConnectionBuilder<DbConnection> WithUri(string uri);
}
```

Expand Down Expand Up @@ -163,20 +163,18 @@ Chain a call to `.OnConnect(callback)` to your builder to register a callback to
```csharp
class DbConnectionBuilder<DbConnection>
{
public DbConnectionBuilder<DbConnection> OnConnectError(Action<ErrorContext, SpacetimeDbException> callback);
public DbConnectionBuilder<DbConnection> OnConnectError(Action<Exception> callback);
}
```

Chain a call to `.OnConnectError(callback)` to your builder to register a callback to run when your connection fails.

A known bug in the SpacetimeDB Rust client SDK currently causes this callback never to be invoked. [`OnDisconnect`](#callback-ondisconnect) callbacks are invoked instead.

#### Callback `OnDisconnect`

```csharp
class DbConnectionBuilder<DbConnection>
{
public DbConnectionBuilder<DbConnection> OnDisconnect(Action<ErrorContext, SpacetimeDbException> callback);
public DbConnectionBuilder<DbConnection> OnDisconnect(Action<DbConnection, Exception?> callback);
}
```

Expand All @@ -187,11 +185,11 @@ Chain a call to `.OnDisconnect(callback)` to your builder to register a callback
```csharp
class DbConnectionBuilder<DbConnection>
{
public DbConnectionBuilder<DbConnection> WithToken(string token = null);
public DbConnectionBuilder<DbConnection> WithToken(string? token);
}
```

Chain a call to `.WithToken(token)` to your builder to provide an OpenID Connect compliant JSON Web Token to authenticate with, or to explicitly select an anonymous connection. If this method is not called or `None` is passed, SpacetimeDB will generate a new `Identity` and sign a new private access token for the connection.
Chain a call to `.WithToken(token)` to your builder to provide an OpenID Connect compliant JSON Web Token to authenticate with, or to explicitly select an anonymous connection. If this method is not called or `null` is passed, SpacetimeDB will generate a new `Identity` and sign a new private access token for the connection.

#### Method `Build`

Expand Down Expand Up @@ -894,7 +892,7 @@ The `Reducers` property of the context provides access to reducers exposed by th

## Type `ErrorContext`

An `ErrorContext` is an [`IDbContext`](#interface-idbcontext) augmented with an `Event` property. `ErrorContext`s are to connections' [`OnDisconnect`](#callback-ondisconnect) and [`OnConnectError`](#callback-onconnecterror) callbacks, and to subscriptions' [`OnError`](#callback-onerror) callbacks.
An `ErrorContext` is an [`IDbContext`](#interface-idbcontext) augmented with an `Event` property. `ErrorContext`s are passed to subscriptions' [`OnError`](#callback-onerror) callbacks.

| Name | Description |
| ----------------------------------------- | ------------------------------------------------------ |
Expand Down