Joe
10/26/2020, 5:26 PMclass MainActivity() : AppCompatActivity(), DIAware {
override val di by di()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
My application:
class PromptsApplication: Application(), DIAware {
override val di by DI.lazy { }
}
The exception:Alec Muffett
11/01/2020, 8:36 PMAppConfig
instance — containing references to objects that implement interfaces like DB: IDatabase
, etc — and pass that appConfig
into the constructors that implemented [various interfaces] for my service.
All very typical factory-pattern stuff - the (for example) appConfig.DB.query()
methods would then be used by service methods (via a "retrieval"-type approach) and the appConfig reference itself would be blindly passed on to any child-factories which need to be created.
But I am learning Kodein and I am messing around with this blog post which suggests making the companion object for Foo : IFoo
into a FooFactory
by declaring a companion object { fun create() : IFoo = ... }
method.
With that context, QUESTION: What's the proper Kotlin & Kodein approach to solving the problem of passing an instantiated appConfig
reference into a FooFactory
that is the companion object of Foo
? In fact, would this be stupid to do? I am trying to avoid endless invocations of Foo(appConfig: DI)
by passing appConfig
into the FooFactory
when I create the FooFactory
,
I could maybe declare Foo.appConfig
as a lateinit
var in the Foo
factory/companion-object, and then set it via a static method call, but I feel sure that there must be a better, more typical way in Kodein - possibly modules?Merseyside
11/02/2020, 9:58 AMAlec Muffett
11/03/2020, 7:48 AMJoost Klitsie
11/03/2020, 11:44 AMjmfayard
11/03/2020, 8:53 PMMarek Defeciński
11/04/2020, 9:11 AMzalewski.se
11/05/2020, 3:08 AMloadModule/unloadModule
, what’s the Kodein way for it? 🙂zalewski.se
11/05/2020, 11:53 AMAlec Muffett
11/06/2020, 2:00 PMMohsen
11/13/2020, 4:42 PMjeggy
11/21/2020, 9:04 PMSlackbot
11/25/2020, 1:54 AMJohn O'Reilly
11/25/2020, 5:27 PMsalomonbrys
11/26/2020, 5:28 PMsalomonbrys
11/27/2020, 5:12 PMSergio Casero
12/04/2020, 1:13 PMAlfred Lopez
12/13/2020, 9:52 PMval kodeinContainer = DI {
bind<MyInterface>(tag = "com.dude.MyInterfaceImpl1") with provider {MyInterfaceImpl1()}
bind<MyInterface>(tag = "com.dude.MyInterfaceImpl2") with provider {MyInterfaceImpl2()}
}
but can you do this dynamically? For example, like....
object MyInjector {
val kodeinContainer = DI {}
}
fun main() {
MyInnjector.kodeinContainer.bind<...>(...) ...
}
nimrod
12/16/2020, 2:48 PMJohn O'Reilly
12/22/2020, 9:12 AMNick
12/23/2020, 6:27 PMromainbsl
12/28/2020, 10:41 AMYaroslav Nesterov
12/31/2020, 5:35 PMimplementation("org.kodein.db:kodein-db-jvm:$kodein_db")
implementation("org.kodein.db:kodein-db-serializer-kotlinx:$kodein_db")
implementation("org.kodein.db:kodein-db-serializer-kryo-jvm:$kodein_db")
leads to java.lang.NoClassDefFoundError: Failed resolution of: Lorg/kodein/db/leveldb/jvm/LevelDBJvm
implementation("org.kodein.db:kodein-db:$kodein_db")
implementation("org.kodein.db:kodein-db-jvm:$kodein_db")
implementation("org.kodein.db:kodein-db-serializer-kotlinx:$kodein_db")
implementation("org.kodein.db:kodein-db-serializer-kryo-jvm:$kodein_db")
leads to Duplicate class org.kodein.db.impl.AbstractDBFactory found in modules jetified-kodein-db-debug-runtime (org.kodein.db:kodein-db-android-debug:0.4.0-beta) and jetified-kodein-db-jvm-0.4.0-beta (org.kodein.db:kodein-db-jvm:0.4.0-beta)
for 99 classes
implementation("org.kodein.db:kodein-db:$kodein_db")
implementation("org.kodein.db:kodein-db-serializer-kotlinx:$kodein_db")
implementation("org.kodein.db:kodein-db-serializer-kryo-jvm:$kodein_db")
leads to java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/my.app.debug-PdUtRd44w96MN7OUXipZlg==/base.apk"],nativeLibraryDirectories=[/data/app/my.app.debug-PdUtRd44w96MN7OUXipZlg==/lib/arm64, /system/lib64, /system/vendor/lib64]]] couldn't find "libkodein-leveldb-jni.so"
what am I doing wrong? kts
mandatory? I still have the build.gradle
ianbrandt
01/06/2021, 12:09 AMAnthony f
01/07/2021, 2:57 PMsalomonbrys
01/08/2021, 4:34 PMindexSet
no longer exists as Set<Index>
has been replaced by Map<String, Any>
. Simply replace indexSet
with mapOf
and you should be good to go!
Please let me know if there's anything we can do to help 🙂. We are very interested in feedback for Kodein-DB beta!Marek Defeciński
01/11/2021, 6:48 AMoverride val di: DI by subDI(di()) {
Type mismatch.
Required: DI
Found: DIPropertyDelegateProvider<Any?>ian.shaun.thomas
02/03/2021, 7:07 PMJoost Klitsie
02/04/2021, 4:17 PMromainbsl
02/05/2021, 4:08 PMromainbsl
02/05/2021, 4:08 PMBig Chungus
02/06/2021, 6:34 PMCould not determine the dependencies of task ':app:jsPackageJson'.
> Could not resolve all dependencies for configuration ':app:jsNpm'.
> Could not resolve org.kodein.di:kodein-di:{require 7.3.0; reject _}.
Required by:
project :app
> No matching variant of org.kodein.di:kodein-di:7.3.0 was found. The consumer was configured to find a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js', attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir' but:
Looks like something did not publish rightromainbsl
02/08/2021, 8:23 AMJoost Klitsie
02/08/2021, 9:56 PMromainbsl
02/16/2021, 4:29 PMJoost Klitsie
02/16/2021, 5:40 PMromainbsl
02/16/2021, 7:32 PM