question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a RequestHandler interface that returns IAsyncEnumerable

See original GitHub issue

Now that we have C# 8.0, it would be nice if we had an interface such as IStreamRequestHandler<TRequest, TResponse> with method

public async IAsyncEnumerable<TResponse> Handle(TRequest, CancellationToken)
{
}

Instead of needing another allocation for a Task<IAsyncEnumerble<TResponse>> using the existing IRequestHandler<TRequest, IAsyncEnumerable<TResponse>>.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:31
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

13reactions
jbogardcommented, Apr 7, 2021

Yeah I’d like to open it up to feedback on the API and approach. It’s a big change 😃

1reaction
ThomasSkyldahlcommented, Sep 18, 2020

How would you handle the difference in signature with the single Send

Should we do IStreamRequest and IStreamRequestHandler and stick to the Send() method for both IRequest and IStreamRequest both interfaces could inherit IBaseRequest but IMediator with have a method for both request types

as one Returns Task<T> and the other returns IAsyncEnumerable<T>

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can we use 'yield return' to return IAsyncEnumerable ...
Basically this method retrieve paginated data from MongoDB collection and convert it to byte array asynchronously and returns it to the caller. ...
Read more >
IAsyncEnumerable with yield in C# - Code Maze
Let's learn about IAsyncEnumerable and the way to iterate over an IEnumerable collection asynchronously with the yield keyword.
Read more >
Return iasyncenumerable from controller. IAsyncEnumerable ...
Return iasyncenumerable from controller. IAsyncEnumerable is used within an async method that uses the "yield" keyword. One advantage of using this type is ......
Read more >
IAsyncEnumerable<T> Interface
Returns an enumerator that iterates asynchronously through the collection. Extension Methods. ConfigureAwait<T>(IAsyncEnumerable<T>, Boolean). Configures how ...
Read more >
IAsyncEnumerable - C# Tutorial
It returns an IAsyncEnumerable <T> interface that iterates the sequences asynchronously. The IAsyncEnumerable<T> has the GetAsyncEnumerator() method that ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found