Hello guys, I'm using Koin Annotations in an <andr...
# koin
a
Hello guys, I'm using Koin Annotations in an android project. Actually, I'm migrating it from Dagger/Hilt to Koin. I've migrated most parts except for couple of objects annotated with Hilt
@FragmentScoped
. How do I achieve this in Koin. This object is being injected to an AbstractFragment which has many concrete implementations. Here's the existing structure:
Copy code
@Provides
@FragmentScoped
fun provideMarkwonEditor(markwon: Markwon): MarkwonEditor {}


@AndroidEntryPoint
abstract class AbstractNotesFragment(): Fragment() {

    @Inject
    lateinit var markwonEditor: MarkwonEditor
}

@AndroidEntryPoint
class FragmentA : AbstractNotesFragment()


@AndroidEntryPoint
class FragmentB : AbstractNotesFragment()
The way I thought I would implement is to do a
@Scope(AbstractNotesFragment::class)
and a
@Scoped
on the MarkwonEditor object, but I don't know if that will share the instance with FragmentA and FragmentB. What's the proper way to do this?
a
@Scope(AbstractNotesFragment::class) will scope your instance to the AbstractNotesFragment class
I don't know if that will share the instance with FragmentA and FragmentB
then you need something else? like sharing at parent activity level?