Can i wrap a default value in a deffered type? ```...
# getting-started
a
Can i wrap a default value in a deffered type?
Copy code
MyClass(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
Copy code
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?
r
Perhaps with
CompletableDeferred
? https://github.com/Kotlin/kotlinx.coroutines/blob/5eca49cfcb25acefaf10ec9b997de537c653b47e/kotlinx-coroutines-core/common/src/CompletableDeferred.kt#L70-L74
Copy code
MyClass(options: Deferred<Map<String, String>> = CompletableDeferred(emptyMap())) {
}
Cant say whether it's 'idiomatic'.
👀 1