Skip to content

Allow top-level stream<T> values - #19

Draft
scothis wants to merge 1 commit into
componentized:mainfrom
scothis:stream
Draft

scothis wants to merge 1 commit into
componentized:mainfrom
scothis:stream

Conversation

@scothis

@scothis scothis commented Oct 7, 2026

Copy link
Copy Markdown
Member

A function may also return a stream<T> of any other supported type, written as a list of the stream's items. A stream with items must be returned by an async function, which writes the items as the caller reads them, then closes the stream. An empty stream, [], may be returned by any function. Calling an async function that returns a stream needs a runtime with support for the component model's async features, e.g. Wasmtime with component-model-async enabled.

/// @value [1, 1, 2, 3, 5, 8]
fibonacci: async func() -> stream<u32>;

A function may also return a `stream<T>` of any other supported type,
written as a list of the stream's items. A stream with items must be
returned by an `async` function, which writes the items as the caller
reads them, then closes the stream. An empty stream, `[]`, may be
returned by any function. Calling an `async` function that returns a
stream needs a runtime with support for the component model's async
features, e.g. Wasmtime with `component-model-async` enabled.

```wit
/// @value [1, 1, 2, 3, 5, 8]
fibonacci: async func() -> stream<u32>;
```

Signed-off-by: Scott Andrews <scott@andrews.me>
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.

1 participant