Cause of backward compatibility, more hackintosh solution could be using invoke
Copy code
class MyClass private constructor(params) {
companion object {
suspend operator fun invoke(params): MyClass {
// do your suspension here
return MyClass(params)
}
}
}
💯 2
s
streetsofboston
02/26/2020, 2:14 PM
Good question. Not entirely sure, but having objects only partially constructed while a thread goes off and do something else feels odd to me 🙂
You can launch/async parallel code in constructors, though.
☝️ 1
a
Animesh Sahu
02/26/2020, 2:15 PM
Call it just like any other constructor
s
streetsofboston
02/26/2020, 2:15 PM
And what @Animesh Sahu showed is a nice workaround 🙂, by using a factory method