{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-dotnet/issues/12","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-dotnet/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-dotnet/issues/12/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-dotnet/issues/12/events","html_url":"https://github.com/GoogleCloudPlatform/gcloud-dotnet/issues/12","id":119082580,"number":12,"title":"How do we want to model asynchronous collection fetching?","user":{"login":"jskeet","id":17011,"avatar_url":"https://avatars.githubusercontent.com/u/17011?v=3","gravatar_id":"","url":"https://api.github.com/users/jskeet","html_url":"https://github.com/jskeet","followers_url":"https://api.github.com/users/jskeet/followers","following_url":"https://api.github.com/users/jskeet/following{/other_user}","gists_url":"https://api.github.com/users/jskeet/gists{/gist_id}","starred_url":"https://api.github.com/users/jskeet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jskeet/subscriptions","organizations_url":"https://api.github.com/users/jskeet/orgs","repos_url":"https://api.github.com/users/jskeet/repos","events_url":"https://api.github.com/users/jskeet/events{/privacy}","received_events_url":"https://api.github.com/users/jskeet/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-dotnet/labels/discussion","name":"discussion","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-11-26T17:22:46Z","updated_at":"2015-12-04T18:00:48Z","closed_at":null,"body":"Scenario: I want to fetch many books from the bookshelf, but I don't want to do all the paging myself. The client should just do that for me, right?\r\n\r\nFor the synchronous approach, that's easy - I can return an `IEnumerable<Book>` and use an iterator block, fetching the next page when I need to. (At a later date we can consider background fetching...)\r\n\r\nFor the asynchronous approach, I've currently got two methods in my common pagination support class:\r\n- `FetchAsync`, returns an `IAsyncEnumerable<Book>` (where `IAsyncEnumerable<T>` is defined in the Ix-Async library)\r\n- `FetchAllAsync`, returns a `Task<IList<Book>>`\r\n\r\nThe idea being that sometimes I want to iterate (asynchronously) and lazily perform the requests, and other times I just want to get the whole lot, asynchronously.\r\n\r\nSo far, so good.\r\n\r\nProposal: Ditch `FetchAllAsync`, and just have the method returning `IAsyncEnumerable<Book>`\r\n\r\nConcern: Help, I don't know what one of those is! I just want a list!\r\n\r\nMitigation: That's okay, call `ToList(CancellationToken)` on it, and you get a `Task<List<Book>>`. That functionality is provided by Ix-Async already... along with other standard LINQ operators, and `ForEachAsync` etc.\r\n\r\nSo it's definitely easy to do what you want with an `IAsyncEnumerable<T>`, but do we think it's discoverable enough? I'm pretty sure that developers will know what to do with a `Task<IList<Book>>`, but I would prefer to just have one async method and one sync method if possible. (They're going to be overloaded anyway, and we need to be careful with naming etc...)"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-dotnet/issues/comments/162036083","html_url":"https://github.com/GoogleCloudPlatform/gcloud-dotnet/issues/12#issuecomment-162036083","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-dotnet/issues/12","id":162036083,"user":{"login":"mmdriley","id":1052311,"avatar_url":"https://avatars.githubusercontent.com/u/1052311?v=3","gravatar_id":"","url":"https://api.github.com/users/mmdriley","html_url":"https://github.com/mmdriley","followers_url":"https://api.github.com/users/mmdriley/followers","following_url":"https://api.github.com/users/mmdriley/following{/other_user}","gists_url":"https://api.github.com/users/mmdriley/gists{/gist_id}","starred_url":"https://api.github.com/users/mmdriley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmdriley/subscriptions","organizations_url":"https://api.github.com/users/mmdriley/orgs","repos_url":"https://api.github.com/users/mmdriley/repos","events_url":"https://api.github.com/users/mmdriley/events{/privacy}","received_events_url":"https://api.github.com/users/mmdriley/received_events","type":"User","site_admin":false},"created_at":"2015-12-04T18:00:48Z","updated_at":"2015-12-04T18:00:48Z","body":"Yes, like [File.ReadLines](https://msdn.microsoft.com/en-us/library/dd383503(v=vs.110).aspx) and [File.ReadAllLines](https://msdn.microsoft.com/en-us/library/s2tte0y1(v=vs.110).aspx), we'll have the efficient one and the easy/discoverable one. :)"}}