Absolutely! Useful for classes that do I/O in their constructor. This is part of the path to zero I/O on UI thread. I'm prototyping it for shared preferences on Android
g
groostav
04/14/2018, 4:17 PM
I think this kind of non-trivial constructor stuff is better left to factory methods, which is arguably what your doing with
suspend op fun invoke()
, but I fear you risk turning your code into scala
groostav
04/14/2018, 4:18 PM
an explicit method like
load
(or
loadAsync(): AndroidFuture<Prefs>()
) might be a better idea, especially if you want java interop