david-wg2
08/01/2019, 10:32 AMobject Config {
val port = System.getenv("PORT") ?: 8080
}
Big Chungus
08/01/2019, 10:35 AMdavid-wg2
08/01/2019, 10:36 AMBig Chungus
08/01/2019, 10:36 AMclass ObjectManager {
init {
Object1
Config
AnotherObject
}
}
fun main() {
ObjectManager()
}
diesieben07
08/01/2019, 10:38 AMobject
is) is not the right pattern for youdavid-wg2
08/01/2019, 10:42 AMConfig = Config()
on startup 🤔init()
methodBig Chungus
08/01/2019, 10:43 AMdavid-wg2
08/01/2019, 10:43 AMBig Chungus
08/01/2019, 10:44 AMdavid-wg2
08/01/2019, 10:45 AMBig Chungus
08/01/2019, 10:47 AMCasey Brooks
08/01/2019, 1:53 PMobject
initialized at a specific time, you’re tying it to the application lifecycle.
Dependency Injection is definitely the way to go here, for managing lifecycle-aware “global” objects.Jørund B. Fagerjord
08/05/2019, 7:32 AMYou can have the Kodein object being statically available (in Android, for example, it is common to use a property of the Application object)https://kodein.org/Kodein-DI/?6.3/getting-started Wouldn't this also have the same memory footprint?