diff --git a/packages/sdk/src/db_connection_impl.ts b/packages/sdk/src/db_connection_impl.ts index 80eda9a..a2d2b33 100644 --- a/packages/sdk/src/db_connection_impl.ts +++ b/packages/sdk/src/db_connection_impl.ts @@ -271,7 +271,8 @@ export class DBConnectionImpl * spacetimeDBClient.subscribe(["SELECT * FROM User","SELECT * FROM Message"]); * ``` */ - subscribe( + // This is marked private but not # because we need to use it from the builder + private subscribe( queryOrQueries: string | string[], onApplied?: (ctx: EventContextInterface) => void, _onError?: (ctx: EventContextInterface) => void diff --git a/packages/sdk/src/db_context.ts b/packages/sdk/src/db_context.ts index a44da39..35f21d2 100644 --- a/packages/sdk/src/db_context.ts +++ b/packages/sdk/src/db_context.ts @@ -92,7 +92,7 @@ export class SubscriptionBuilder { /// Consumes the `SubscriptionBuilder`, /// because the callbacks are not necessarily `Clone`. subscribe(query_sql: string[]): void { - this.db.subscribe(query_sql, this.#onApplied, this.#onError); + this.db['subscribe'](query_sql, this.#onApplied, this.#onError); } } diff --git a/packages/sdk/tests/spacetimedb_client.test.ts b/packages/sdk/tests/spacetimedb_client.test.ts index bdf7851..8098c65 100644 --- a/packages/sdk/tests/spacetimedb_client.test.ts +++ b/packages/sdk/tests/spacetimedb_client.test.ts @@ -45,8 +45,10 @@ describe('SpacetimeDBClient', () => { .withWSFn(wsAdapter.createWebSocketFn.bind(wsAdapter)) .build(); - client.subscribe('SELECT * FROM Player'); - client.subscribe(['SELECT * FROM Position', 'SELECT * FROM Coin']); + client.subscriptionBuilder().subscribe(['SELECT * FROM Player']); + client + .subscriptionBuilder() + .subscribe(['SELECT * FROM Position', 'SELECT * FROM Coin']); let called = false; client.onConnect(() => {