View module2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module { | |
factoryOf(::StaffListerImpl) bind StaffLister::class | |
factoryOf(::SearchBox) | |
} |
View module1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module { | |
factory { StaffListerImpl() as StaffLister } | |
factory { SearchBox (get()) } | |
} |
View CheckModulesTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CheckModulesTest : KoinTest { | |
@Test | |
fun verifyKoinApp() { | |
koinApplication { | |
modules(module1, module2) | |
checkModules() | |
} | |
} | |
} |
View ContentView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
let staff = SearchBoxHelper().findByName(name: "Pamela Hill") | |
var body: some View { | |
Text(staff) | |
} | |
} |
View SearchBoxHelper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.koin.core.component.KoinComponent | |
import org.koin.core.component.inject | |
... | |
class SearchBoxHelper : KoinComponent { | |
private val searchBox : SearchBox by inject() | |
fun findByName(name: String) : String = | |
searchBox.findStaffMemberByName(name).toString() | |
} |
View MainActivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.koin.android.ext.android.inject | |
... | |
class MainActivity : AppCompatActivity() { | |
private val searchBox: SearchBox by inject() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) |
View iOSApp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@main | |
struct iOSApp: App { | |
init() { | |
HelperKt.doInitKoinApp() | |
} | |
… | |
} |
View Helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun initKoinApp(){ | |
initKoin() | |
} |
View MyApplication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApplication : Application() { | |
override fun onCreate() { | |
super.onCreate() | |
initKoin() | |
} | |
} |
View SearchBox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.koin.core.KoinApplication | |
import org.koin.core.context.startKoin | |
import org.koin.core.module.Module | |
import org.koin.dsl.module | |
... | |
object Modules { | |
val appModule = module { | |
factory { StaffListerImpl() as StaffLister } | |
factory { SearchBox (get()) } |
NewerOlder