[Blazor] Support for IEnumerable/IAsyncEnumerable on JS interop
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
IEnumerable and IAsyncEnumerable are "special" in the sense that they are "lazy" and allow producing more than one value. In the end, they represent a contract between the producer and the consumer in the form of the `Current` and `MoveNext` protocol.
Right now, JS interop supports returning a `Task` which is a similar type of contract in the sense that it represents a value that will be available in the future and that the framework "special cases". We can think of `IAsyncEnumerable` as a collection of values that are produced asynchronously (or the sequence version of a task).
This analogy is not accurate in formal terms, but it gets the point across that if we have built-in support for tasks, there's no reason why we wouldn't want to support IAsyncEnumerable understood as a sequence of tasks.
This would for example enable modeling scenarios like JS triggered state updates into the .NET side in a more natural way without requiring in many cases define an "equivalent" protocol.
`IAsyncEnumerable` can be supported everywhere, while `IEnumerable` can only be supported on the InProcessJsRuntime.
Contributor guide
Assessment
This issue has not been assessed yet.