XDracam / unity-corelibrary

Collection of classes and extension methods that make life with Unity3D more comfortable
MIT License
16 stars 3 forks source link

Async Select in order #75

Open XDracam opened 4 years ago

XDracam commented 4 years ago

We want a method similar to LINQ Select, which takes an IEnumerable<A> and a Func<A, Task<B>> and awaits the results of applying the func to each argument in a linear order, e.g. the second task is started once the first one finishes.

This contrasts Task.WhenAll, since Tasks are eagerly ran and thus not referentially transparent. In order to run tasks one after the other, we need to lazily create the Tasks themselves, hence the usage in a Select (and maybe Collect) method.

These should have obvious naming that highlights the sequential processing of their sequences' values.