clockworklabs / clockworklabs/SpacetimeDB
TypeScript Client QuickStart Updates
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 25.2k
- Forks
- 1.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 46
Description
Hi there -
A few things I noticed for the TypeScript QuickStart:
useRefis used in the code but not imported, I added it to the import on line 1, so it is nowimport React, {useEffect, useState, useRef} from "react";- The logo import on line 2 is not used, so I removed that line.
- For the line :
var user = User.filterByIdentity(local_identity?.current?.toUint8Array()!);It should not be converted to a Uint8Array, so the line I got working was:var user = User.filterByIdentity(local_identity?.current!); - I had to update the
tsconfig.jsonfile that was generated bycreate-react-appto saytarget=es6in order to get the iterators to work. I'd suggest changing the instruction to tell folks they'll have to do that, as it doesn't appear to be possible to make it es6 as part ofcreate-react-app. - For the line:
var identityStr = new Identity(user.identity).toHexString();it does need to be converted to match the constructor, so the line I got working was:var identityStr = new Identity(user.identity.toUint8Array()).toHexString(); - For the line:
var spacetimeDBClient = new SpacetimeDBClient("ws://localhost:3000", "chat", token);the text says 'replace<module_name>with the name you chose', but<module_name>isn't in the code, it's hard-set tochat. So I believe that line should bevar spacetimeDBClient = new SpacetimeDBClient("ws://localhost:3000", "<module_name>", token); local_identityisn't a very Typescript-y variable name, so it should probably be tweaked tolocalIdentityor something like that.
It's possible this Issue should be over in this repo, since thats where this example code lives, but I'm not sure.
I think that's all the tweaks I had to make to get it running. I hope that helps! 👍🏻
One general piece of feedback would be to put working versions of the whole thing into a repo somewhere so it can be copied in one go rather than pieced together. I like the explanations a lot, but some of the "go back to this function and add this line" stuff was a bit tricky. I see there is a PR on the typescript-sdk repo that tries to do this, but has extra stuff.
Cheers!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked TypeScript QuickStart guide and compare its imports, identity handling, client construction, naming, and tsconfig.json instructions with the reported working versions. Check the referenced typescript-sdk repository and branch to confirm where the example lives. Done means the guide's code and setup steps work as written in a fresh React TypeScript app.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100