https://kotlinlang.org logo
#ktor
Title
# ktor
a

Alan Pierri

02/08/2019, 6:21 PM
Hi everyone! Maybe someone encountered the same challenge...
Copy code
lateinit var foo: Foo

fun Application.main() {
  if(!::foo.isInitialized){
    // Initialize foo, which is heavy processing...
  }
  // More code...
}
Is there any way I can avoid re-initializing foo with Autoreload? I hoped the initialization check would work, but it won't.
r

Riccardo Montagnin

02/08/2019, 7:25 PM
Can't you move the initialization in other file that is not watched by autoreload? Would that work for you?
b

Brad Murray

02/12/2019, 9:46 PM
I've done this in some automation work elsewhere where an empty dotfile was used to mark that initialisation is complete, and the code just checked for it. Makes it easy to reinit when you want to, and works fine with auto-reloading as well.
2 Views