Deferred has no map function
See original GitHub issuethere should be a function
Deferred<R>.map(map:(R)->T) : Deferred<T>
it is easy to implement yourself, but it is a bit confusing that it is missing. there might be other functions to consider, like
Deferred<Deferred<T>>.flatten() : Deferred<T>
or
List<Deferred<T>>.combine() : Deferred<List<T>>
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
data.map is not a function
The answer is to use data.products.map , not to wrap data in an array. Your answer causes the entire data object to be...
Read more >TypeError: object.map is not a function in JavaScript
The "object.map is not a function" error occurs because the map method is not implemented on objects. To iterate over an object, use...
Read more >Mapping on Deferred Contexts - Windows drivers
The runtime can map a dynamic resource (through a call to the driver's ResourceMap function) on a deferred context, as the Direct3D version ......
Read more >A deferred problem or something else?
I am passing in a single query to execute, but it seems to execute for every key for every key. If there are...
Read more >Map | API Reference | ArcGIS API for JavaScript 3.42
The load event is fired after the first layer has been added to the map. At this point, the map is fully functional....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Le me add a note explaining why suspending function are preferable to functions returning Futures (incl. Deferred, Job, and others):
Marking a function
suspend
in Kotlin is semantically the same as making the function returning a future in Java. A suspending function IS a callback function. The only difference, is that the callback mechanism is hidden by the compiler, and we don’t actually see the callback, which make the code clearer. But it is a callback.So, the whole point of Kotlin coroutines is to not use callback and future anymore. Instead we use suspending functions which lets us write code like sequential code while keeping the benefits of future and callbacks.
Therefore declaring a function
fun foo(): Deffered<Int>
instead ofsuspend fun foo(): Int
is basically loosing the whole point of Kotlin coroutines. This could be done with any future library.Consider this Java code:
In this code we have to use Future, combine, map etc. or, because there is no better choice.
But the point of kotlin coroutines is to provide the
suspend
keyword in the language which hide all the complexity.So here is the Kotlin idiomatic equivalent of the Java code above:
@SolomonSun2010 Thank. We’ve studied Dart design while working on Kotlin coroutines and we had put quite a lot of thought into making sure we don’t fall into the same futures trap as Dart did. As a result, the Dart example you’ve given looks much simpler (and nicer) in Kotlin: