File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
packages/client/src/client Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Type-checked examples for `streamableHttp.ts`.
3+ *
4+ * These examples are synced into JSDoc comments via the sync-snippets script.
5+ * Each function's region markers define the code snippet that appears in the docs.
6+ *
7+ * @module
8+ */
9+
10+ /* eslint-disable unicorn/consistent-function-scoping -- examples must live inside region blocks */
11+
12+ import type { ReconnectionScheduler } from './streamableHttp.js' ;
13+
14+ // Stub for a hypothetical platform-specific background scheduling API
15+ declare const platformBackgroundTask : {
16+ schedule ( callback : ( ) => void , delay : number ) : number ;
17+ cancel ( id : number ) : void ;
18+ } ;
19+
20+ /**
21+ * Example: Using a platform background-task API to schedule reconnections.
22+ */
23+ function ReconnectionScheduler_basicUsage ( ) {
24+ //#region ReconnectionScheduler_basicUsage
25+ const scheduler : ReconnectionScheduler = ( reconnect , delay ) => {
26+ const id = platformBackgroundTask . schedule ( reconnect , delay ) ;
27+ return ( ) => platformBackgroundTask . cancel ( id ) ;
28+ } ;
29+ //#endregion ReconnectionScheduler_basicUsage
30+ return scheduler ;
31+ }
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ export interface StreamableHTTPReconnectionOptions {
9494 * pending reconnection.
9595 *
9696 * @example
97- * ```ts
97+ * ```ts source="./streamableHttp.examples.ts#ReconnectionScheduler_basicUsage"
9898 * const scheduler: ReconnectionScheduler = (reconnect, delay) => {
9999 * const id = platformBackgroundTask.schedule(reconnect, delay);
100100 * return () => platformBackgroundTask.cancel(id);
You can’t perform that action at this time.
0 commit comments