kodein

Simple Kotlin Project does not show any UI

瘦欲@ 提交于 2021-02-04 08:40:21
问题 I have a very simple Android Project in Kotlin. Just to dig in Kodein. I can not see the two TextViews in the main_layout? I have used MVP pattern for the only MainActivity I have there.. The app starts without a crash and is show a blank white screen. Any hints? BaseActivity: abstract class BaseActivity<V : BasePresenter.View> : AppCompatActivity(), BasePresenter.View { protected abstract val layoutResourceId : Int protected abstract val presenter : BasePresenter<V> val kodeinMu = LazyKodein

In Kodein dependency injection, how can you inject instances of Kodein itself into instances?

时光毁灭记忆、已成空白 提交于 2020-01-03 16:56:17
问题 In Kodein, I have modules imported into a parent module, and sometimes the classes need an instance of Kodein so they can do injection themselves later. The problem is this code: val parentModule = Kodein { import(SomeService.module) } Where SomeService.module needs the Kodein instance for later, but Kodein isn't yet created. Passing it later into the module seems like a bad idea. In Kodein 3.x I see there is the kodein-conf module that has a global instance, but I want to avoid the global.

How to Rebind the Module at secound time called in kodein?

旧时模样 提交于 2019-12-24 20:54:41
问题 I have an android app, its developed in kotlin, also we use kodein dependence for binding the data.When the binding the data first time it will bind correctly but it does not bind at second time call. inner class CallmyClass() : MultiDexApplication(), KodeinAware { val diModel = Kodein.Module { bind<ExchangeRateProvider>() with singleton { CryptoCompareExchangeProvider(this@App, instance()) } bind<SyncProgressProvider>() with singleton { SyncProgressProvider() } bind<WallethKeyStore>() with

Why a viewmodel factory is needed in Android?

寵の児 提交于 2019-12-18 03:59:11
问题 We have been discussing about this but we don't know the reason of creating a viewmodel factory to create a viewmodel instead of instantiate the viewmodel directly. What is the gain of creating a factory that just creates the viewmodel? I just put a simple example of how I did it without Factory here is the kodein module: val heroesRepositoryModel = Kodein { bind<HeroesRepository>() with singleton { HeroesRepository() } bind<ApiDataSource>() with singleton { DataModule.create() } bind

How can I use Kodein's direct retrieval to fetch a dependency bound as a factory?

。_饼干妹妹 提交于 2019-12-11 14:59:35
问题 Consider the following injector: class Injector constructor(secretSauce: SecretSauce) { val kodein = Kodein { bind<SpicyBeans>() with factory { beans: List<Bean>, herbs: List<Herb> -> SpicyBeans(secretSauce, beans, herbs) } } } And the following business logic: class TastyMeal { private lateinit var injector : Kodein private lateinit var spicyBeans : SpicyBeans fun initialiseWithInjector(kodein : Kodein) { injector = kodein val herbs = listOf(Coriander(), Cumin()) val beans = listOf(Pinto(),

Kodein vs Dagger - Can't Get Dagger Working w/ Multiple Modules

北慕城南 提交于 2019-12-09 05:07:25
( x-post from /r/androiddev ) I would just like to preface this by saying that this is not a "which is better" post; this is strictly a question about how I can build something using Dagger (and how I built it in Kodein to help illustrate the problem). I've been using Kodein for a few years now in several work projects, and I've found it to be so easy to work with, that I never look at Dagger anymore. I started a new personal project, and I thought I'd give Dagger another shot. To keep things simple, I have 3 modules (this is a regular desktop app not an Android one); app common google app

Kodein vs Dagger - Can't Get Dagger Working w/ Multiple Modules

微笑、不失礼 提交于 2019-12-08 06:03:58
问题 (x-post from /r/androiddev) I would just like to preface this by saying that this is not a "which is better" post; this is strictly a question about how I can build something using Dagger (and how I built it in Kodein to help illustrate the problem). I've been using Kodein for a few years now in several work projects, and I've found it to be so easy to work with, that I never look at Dagger anymore. I started a new personal project, and I thought I'd give Dagger another shot. To keep things