chore: add StateSnapshotManager class #119
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part 1 of the ongoing API factory changes for #107
Decided to start breaking these up to make the PRs easier to digest, and start getting the ball rolling faster.
Changes made
StateSnapshotManager
class, which makes it easy to sync external state with React'suseSyncExternalStore
hook.CoderClient
andCoderTokenAuth
Notes
Once the PR is done, I'll start tinkering with things like Proxy objects to start figuring out if there's a way to make the class less error-prone. My hope is that I can make it so that the manager exposes a "mutable snapshot proxy", and when you mutate a property on it, that will automatically run logic to determine if the snapshot has meaningfully changed, and also notify subscriptions
My thinking is that we get the API code working (even if it's less than ideal), get it verified with tests, and then use the tests to guide refactoring.