I use the following notation with `koin-android:3....
# koin
t
I use the following notation with
koin-android:3.3.0
:
Copy code
singleOf<AndroidPreferences> { AndroidPreferencesImpl(GlobalScope) }
When I update to
koin-android:3.4.1
this becomes a compilation error. What is the recommended migration path here?
AndroidPreferences
is an
interface
,
AndroidPreferencesImpl
is a
class
m
Copy code
single { AndroidPreferenceImpl(GlobalScope) } bind AndroidPreferences::class
If you have GlobalScope defined in Koin module, then:
Copy code
singleOf(::AndroidPreferenceImpl) bind AndroidPreferences::class
t
Thank you! That works for me. Was this changed marked as a breaking change in some version? https://github.com/InsertKoinIO/koin/blob/main/CHANGELOG.md
Also, how would you define
GlobalScope
in a module? In the constructor parameter of a class I have no knowledge about the specific type as in
scope: CoroutineScope
.
a
use the OptionDSL with singleOf style:
Copy code
singleOf(::AndroidPreferenceImpl){ bind<AndroidPreferences>() }
t
@arnaud.giuliani Are you missing out
GlobalScope
?
a
for this you need to keep functional style:
single { GlobalScope }
t
How would that match the Coroutine parameter in the constructor? See my question above.
@arnaud.giuliani Ping, in case you did not see my reply. Take your time if you are busy.
a
just inject
Dispatchers
type
t
@arnaud.giuliani Can you please point me to example? How does injecting the dispatcher type (which I already do) help with resolving the
scope
within the class instance?