Add support for subscription
events to WebView's tRPC
#2522
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 PR introduces enhancements to the
appRouter
and theWebviewController
to enable strongly typed event subscription support within a webview.fixes #2516
Enhancements and new features:
Subscription Procedures:
demoBasicSubscription
anddemoComplexSubscription
to demonstrate streaming data from the server to the client using asynchronous generators. These subscriptions handle various scenarios, including client-side unsubscription and server-side abort signals.Router Configuration:
demoRouter
to theappRouter
to organize and manage the new subscription procedures.WebviewController Enhancements:
This pull request to
src/webviews/api/configuration/appRouter.ts
andsrc/webviews/api/extension-server/WebviewController.ts
introduces new subscription procedures and enhanced documentation. The most important changes are grouped by theme below:New Features:
demoBasicSubscription
anddemoComplexSubscription
procedures to demonstrate how to stream data from the server to the client using asynchronous generators.Enhancements:
signal
property toBaseRouterContext
to support subscription cancellation.Documentation:
WebviewController
to clarify its usage with tRPC for handling requests from the webview.Code Organization:
appRouter
to include the newdemoRouter
for better modularity.These changes collectively enhance the functionality, error handling, and integration capabilities of the application, providing a more robust and flexible development environment.