Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IAsyncEnumerable<T> which can be enumerated asynchronously #161

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nelsonprsousa
Copy link

@nelsonprsousa nelsonprsousa commented Feb 18, 2021

Add IAsyncEnumerable which can be enumerated asynchronously.

Usage:

[HttpGet]
public async IAsyncEnumerable<ToDoItem> GetAsyncEnumerable()
{
	await foreach(var todoItem in _repository.GetAsyncEnumerable<ToDoItem>())
	{
		yield return todoItem;
	}
}

@ardalis
Copy link
Owner

ardalis commented Apr 2, 2021

What's the use case for this? What client is going to consume this [HttpGet] call?

@nelsonprsousa
Copy link
Author

What's the use case for this? What client is going to consume this [HttpGet] call?

I was reading some blog posts like this one: https://anthonychu.ca/post/async-streams-dotnet-core-3-iasyncenumerable/ and tested something like that using IAsyncEnumerable and Specification lib

@ardalis
Copy link
Owner

ardalis commented Apr 17, 2021

Ok, I like this, but I've made some pretty major changes to the template recently. Perhaps this is something I should also add to my ApiEndpoints project/package, which this one consumes. And perhaps Specification as well, since this project uses that package's EFRepository. Thoughts?

@nelsonprsousa
Copy link
Author

Ok, I like this, but I've made some pretty major changes to the template recently. Perhaps this is something I should also add to my ApiEndpoints project/package, which this one consumes. And perhaps Specification as well, since this project uses that package's EFRepository. Thoughts?

Tomorrow I'll take a look at ApiEndpoints and Specification packages and I'll get back to you 👍

@ardalis
Copy link
Owner

ardalis commented Jan 11, 2022

Hey @nelsonprsousa did you ever get a chance to see how this would play with the related packages?

@nelsonprsousa
Copy link
Author

nelsonprsousa commented Jan 11, 2022

Hey @nelsonprsousa did you ever get a chance to see how this would play with the related packages?

I didn't have the chance, but I am willing to help. What do you expect?

@ardalis
Copy link
Owner

ardalis commented Jan 11, 2022

Would you mind making an issue suggesting this feature in Ardalis.Specification, showing some code snippets you can borrow from this PR?

I'd like to get some discussion around this in that repo for that package since it seems like the right place to add it (or perhaps not) given this repo leverages its base Repository class.

(I could open the issue but given your interest in the topic I figure it's better if you do)

@nelsonprsousa
Copy link
Author

nelsonprsousa commented Jan 11, 2022

Would you mind making an issue suggesting this feature in Ardalis.Specification, showing some code snippets you can borrow from this PR?

I'd like to get some discussion around this in that repo for that package since it seems like the right place to add it (or perhaps not) given this repo leverages its base Repository class.

(I could open the issue but given your interest in the topic I figure it's better if you do)

Sounds good. Give me some days and I'll open the issue and work on a PR 👍

@nelsonprsousa
Copy link
Author

Closing this PR in favor of ardalis/Specification#229

@ardalis
Copy link
Owner

ardalis commented Jan 20, 2022

I think we're back to looking at putting it here.

@nelsonprsousa
Copy link
Author

I think we're back to looking at putting it here.

Yeap, good discussion, tho! 👍

Give me one day or so to improve this with more examples and unit tests.

@nelsonprsousa nelsonprsousa reopened this Jan 21, 2022
@nelsonprsousa
Copy link
Author

nelsonprsousa commented Jan 26, 2022

@ardalis I rebased this PR since it was already too old with major changes in the main repo.

I'll add unit tests. Should I add some kind of example to some page or how do you see this evolve?

@ardalis
Copy link
Owner

ardalis commented Jan 27, 2022

Yes, an example would be helpful. Maybe another endpoint for a project with a LOT of ToDo items, so that it could stream them as they were read? I'm still not sure when I would use this so I'll trust you to come up with something, ideally without needing to add a bunch more code to support the scenario.

Unit and/or functional tests would be great. Thanks!

@ardalis
Copy link
Owner

ardalis commented Jun 14, 2022

Any update on this or shall I close it?

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.

None yet

2 participants