Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript client SDK API follow-ups #127

Closed
bfops opened this issue Jan 13, 2025 · 1 comment · Fixed by #137 or clockworklabs/SpacetimeDB#2230
Closed

TypeScript client SDK API follow-ups #127

bfops opened this issue Jan 13, 2025 · 1 comment · Fixed by #137 or clockworklabs/SpacetimeDB#2230
Assignees

Comments

@bfops
Copy link
Contributor

bfops commented Jan 13, 2025

  • onConnect callbacks should be registered exclusively with the DbConnectionBuilder, never with the DbConnection. Similar for onDisconnect and onConnectError.
    • Relatedly, the various removeOn methods for these should not exist.
  • DbConnection.wsPromise should not be exposed.
    • The DbConnection should expose a runAsync method, implemented in terms of an advanceOneMessageAsync method.
    • I don't really care if the client advances on its own if you don't call these methods, honestly, though I'd prefer if it didn't. But this should be the canonical way of "blocking" your application on the connection.
  • Rename DBConnection -> DbConnection. Also rename any other DBs to Dbs.
@bfops bfops assigned cloutiertyler and unassigned jsdt Feb 3, 2025
@cloutiertyler
Copy link
Contributor

cloutiertyler commented Feb 8, 2025

  • onConnect callbacks should be registered exclusively with the DbConnectionBuilder, never with the DbConnection. Similar for onDisconnect and onConnectError.
    • Relatedly, the various removeOn methods for these should not exist.
  • DbConnection.wsPromise should not be exposed.
  • The DbConnection should expose a runAsync method, implemented in terms of an advanceOneMessageAsync method.
    • I don't really care if the client advances on its own if you don't call these methods, honestly, though I'd prefer if it didn't. But this should be the canonical way of "blocking" your application on the connection.
  • Rename DBConnection -> DbConnection. Also rename any other DBs to Dbs.

I've implemented the checkmarked ones in #135

I am going to implement the last one in a forthcoming ticket. I am not going to implement the runAsync method because I believe it's impossible to implement with the WebSocket API or at the very least I don't know how to do it. You can't poll the socket, your only choice is to register handlers. This is likely a limitation imposed by browsers. Based on the description, it seems like it could be backwards compatible and made a P2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment