Skip to content

Commit

Permalink
Merge pull request #103 from clockworklabs/tyler/stable-sdk/fix-1
Browse files Browse the repository at this point in the history
Make `subscribe` private
  • Loading branch information
bfops authored Oct 4, 2024
2 parents b8c944c + fa03b0d commit 3c63d5e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/sdk/src/db_connection_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ export class DBConnectionImpl<DBView = any, Reducers = any>
* 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
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/db_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 4 additions & 2 deletions packages/sdk/tests/spacetimedb_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 3c63d5e

Please sign in to comment.