Alex Edwards
10/22/2021, 8:22 PMMyClass(options: Deferred<Map<String, String>> = emptyMap()) {
// This constructor doesn't actually compile, its an example of what i would like to achieve
//some stuff
}
The map passed in here is ultimately wrapped in a promise. currently i have a js snippet that essentially does
options.then { new MyClass(it) }
ideally i would like to move this into my kotlin code but I would still like to handle MyClass()
is there a way i can do this?Richard Gomez
10/22/2021, 8:32 PMCompletableDeferred
?
https://github.com/Kotlin/kotlinx.coroutines/blob/5eca49cfcb25acefaf10ec9b997de537c653b47e/kotlinx-coroutines-core/common/src/CompletableDeferred.kt#L70-L74
MyClass(options: Deferred<Map<String, String>> = CompletableDeferred(emptyMap())) {
}
Cant say whether it's 'idiomatic'.