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

A channel augmenter that encodes and decodes messages as JSON #3309

Conversation

steveluscher
Copy link
Collaborator

Summary

The new web socket channel speaks in strings/buffers. For general use in the JSON RPC Subscriptions API we need it to take in JavaScript objects, send JSON strings over the wire, and parse the strings that come back as JSON.

This is a higher-order component that wraps a RpcSubscriptionsChannel that speaks in strings, and makes it speak in JavaScript objects.

Copy link

changeset-bot bot commented Oct 4, 2024

⚠️ No Changeset found

Latest commit: 0d9069a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines 6 to 8
return {
...channel,
on(type, listener, options) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to Object.freeze this?

I know technically the RpcSubscriptionsChannel type only has two functions (send and on) but since we're destructuring the inner object here, it may be useful to freeze it.

@steveluscher steveluscher force-pushed the 10-02-a_channel_augmenter_that_encodes_and_decodes_messages_as_json branch from fd5fc49 to 1ac504b Compare October 4, 2024 17:56
@steveluscher steveluscher changed the base branch from 10-02-Introducing_channels to graphite-base/3309 October 4, 2024 18:02
@steveluscher steveluscher force-pushed the 10-02-a_channel_augmenter_that_encodes_and_decodes_messages_as_json branch from 1ac504b to a721e9a Compare October 4, 2024 18:04
@steveluscher steveluscher changed the base branch from graphite-base/3309 to master October 4, 2024 18:05
@steveluscher steveluscher force-pushed the 10-02-a_channel_augmenter_that_encodes_and_decodes_messages_as_json branch 3 times, most recently from 3007e83 to 12931ce Compare October 4, 2024 19:26
@steveluscher steveluscher changed the base branch from master to 10-04-revert_no_argument_conditional_type_from_3301 October 4, 2024 19:26
Copy link
Collaborator Author

steveluscher commented Oct 4, 2024

Merge activity

  • Oct 4, 12:27 PM PDT: @steveluscher started a stack merge that includes this pull request via Graphite.
  • Oct 4, 12:30 PM PDT: Graphite rebased this pull request as part of a merge.
  • Oct 4, 12:31 PM PDT: @steveluscher merged this pull request with Graphite.

@steveluscher steveluscher changed the base branch from 10-04-revert_no_argument_conditional_type_from_3301 to graphite-base/3309 October 4, 2024 19:27
@steveluscher steveluscher changed the base branch from graphite-base/3309 to master October 4, 2024 19:28
@steveluscher steveluscher force-pushed the 10-02-a_channel_augmenter_that_encodes_and_decodes_messages_as_json branch from 12931ce to 0d9069a Compare October 4, 2024 19:29
@steveluscher steveluscher merged commit 994441a into master Oct 4, 2024
7 checks passed
@steveluscher steveluscher deleted the 10-02-a_channel_augmenter_that_encodes_and_decodes_messages_as_json branch October 4, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants