Skip to content

Instantly share code, notes, and snippets.

View pahill's full-sized avatar
👩‍🎤

Pamela Hill pahill

👩‍🎤
View GitHub Profile
module {
factoryOf(::StaffListerImpl) bind StaffLister::class
factoryOf(::SearchBox)
}
module {
factory { StaffListerImpl() as StaffLister }
factory { SearchBox (get()) }
}
class CheckModulesTest : KoinTest {
@Test
fun verifyKoinApp() {
koinApplication {
modules(module1, module2)
checkModules()
}
}
}
struct ContentView: View {
let staff = SearchBoxHelper().findByName(name: "Pamela Hill")
var body: some View {
Text(staff)
}
}
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()
}
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)
@main
struct iOSApp: App {
init() {
HelperKt.doInitKoinApp()
}
}
fun initKoinApp(){
initKoin()
}
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
initKoin()
}
}