Skip to content

Commit 3c63d5e

Browse files
authored
Merge pull request #103 from clockworklabs/tyler/stable-sdk/fix-1
Make `subscribe` private
2 parents b8c944c + fa03b0d commit 3c63d5e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

packages/sdk/src/db_connection_impl.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ export class DBConnectionImpl<DBView = any, Reducers = any>
271271
* spacetimeDBClient.subscribe(["SELECT * FROM User","SELECT * FROM Message"]);
272272
* ```
273273
*/
274-
subscribe(
274+
// This is marked private but not # because we need to use it from the builder
275+
private subscribe(
275276
queryOrQueries: string | string[],
276277
onApplied?: (ctx: EventContextInterface) => void,
277278
_onError?: (ctx: EventContextInterface) => void

packages/sdk/src/db_context.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class SubscriptionBuilder {
9292
/// Consumes the `SubscriptionBuilder`,
9393
/// because the callbacks are not necessarily `Clone`.
9494
subscribe(query_sql: string[]): void {
95-
this.db.subscribe(query_sql, this.#onApplied, this.#onError);
95+
this.db['subscribe'](query_sql, this.#onApplied, this.#onError);
9696
}
9797
}
9898

packages/sdk/tests/spacetimedb_client.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ describe('SpacetimeDBClient', () => {
4545
.withWSFn(wsAdapter.createWebSocketFn.bind(wsAdapter))
4646
.build();
4747

48-
client.subscribe('SELECT * FROM Player');
49-
client.subscribe(['SELECT * FROM Position', 'SELECT * FROM Coin']);
48+
client.subscriptionBuilder().subscribe(['SELECT * FROM Player']);
49+
client
50+
.subscriptionBuilder()
51+
.subscribe(['SELECT * FROM Position', 'SELECT * FROM Coin']);
5052

5153
let called = false;
5254
client.onConnect(() => {

0 commit comments

Comments
 (0)