Switch @bufbuild/connect-web to use @bufbuild/connect #471
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.
This updates @bufbuild/connect-web to share logic with @bufbuild/connect-node. Shared types like
ConnectError
,createPromiseClient
, and others live in@bufbuild/connect
, and are re-exported from the other packages.This switch comes with the following improvements and bug fixes:
This also changes the interfaces
Interceptor
andTransport
.To understand this change, it is best to compare the old Transport with the new Transport.
Transport
now has a methodstream()
instead of justserverStream()
, and this method takes anAsyncIterable<I>
as input. This allows us to implement full duplex streaming via the Node.jshttp2
package.This means that the types related to interceptors also had to change (old vs new), but note that a simple interceptor that adds a request header still looks the same:
And intercepting streams actually becomes more straight-forward, thanks to asynchronous iterables: