Suppose I have a suspend function that provides an instance of some interface. How can I use Koin to inject such an instance where required? Like mentioned https://github.com/InsertKoinIO/koin/issues/388
Mark
02/06/2020, 7:39 AM
Iām thinking maybe the best way to go is for the instance to internally lazily perform some suspending init() rather than requiring the caller to explicitly do so.
a
arnaud.giuliani
02/06/2020, 8:15 AM
can you be more explicit? š¤
m
Mark
02/06/2020, 8:25 AM
Suppose I have a singleton that requires a one time call to a suspending function
init()
before it can be used. Ideally any code that wants to use this singleton would call some suspending equivalent of
get()
(or somehow
by inject()
) in such a way that init() is called behind the scenes (presumably in some equivalent to single {} that takes a suspending lambda) only when necessary.