Stream
查看 MarkdownThis page lists the TypeScript SDK names for Streams. The doc comment of each API gives its parameters, defaults, and errors. Read them in the TypeScript SDK API reference.
API names
| Task | TypeScript API | Dex behavior |
|---|---|---|
| Define a Stream and its byte capacity | Stream, with streamCapacityBytes | Capacity and trimming |
| Declare it in the Flow | streams of the PersistenceSchema returned from getPersistenceSchema | Flow definition |
| Write a message from a Step | Stream.write | Write semantics |
| Write text chunks in batches from a Step | Stream.bufferedText | Buffer text chunks |
| Write a message from a Client | Client.writeStream | Write semantics |
| Read the next message | Client.readStream, with the resumeToken of the last message | Resumable reads |
| List retained messages, newest first | Client.listStreamMessages | List messages |
Stream.write works in waitFor, execute, and the Flow timeout handler. An RPC handler cannot write a Stream. Stream.write sends the message immediately and returns nothing. Use Stream.bufferedText in an asynchronous Step.
Example
Example: examples/typescript/src/primitives/stream/stream-flow.ts