Edoardo Luppi
12/15/2023, 10:19 AMmain
functions, on each file inside the same Gradle module.
This means we can develop browser extensions without having to split each extension part on its own module.Artem Kobzar
12/15/2023, 11:54 AMEdoardo Luppi
12/15/2023, 11:55 AMArtem Kobzar
12/15/2023, 11:56 AMEdoardo Luppi
12/15/2023, 11:57 AMArtem Kobzar
12/15/2023, 12:00 PMEagerInitialization
. It will bring effect inside the file, and in per-file I use import "something"
to add it into the "module" file.Artem Kobzar
12/15/2023, 12:00 PMEdoardo Luppi
12/15/2023, 12:03 PMEdoardo Luppi
12/15/2023, 12:08 PMbackground.kt
and a popup.kt
, living in the same module. Each will have a function that must be called when the file is loadedArtem Kobzar
12/15/2023, 12:31 PMEdoardo Luppi
12/15/2023, 12:33 PMUnit
from the functionEdoardo Luppi
12/15/2023, 12:34 PMEdoardo Luppi
12/15/2023, 2:16 PM@file:JsFileName("background")
@Suppress("DEPRECATION")
@OptIn(ExperimentalStdlibApi::class)
@EagerInitialization
val init = background()
fun background() {
println("eager print line")
}
This is outputted:
var init;
function background() {
println('eager print line');
}
function init$init$() {
background();
return Unit_instance;
}
//region block: init
init = init$init$();
//endregion
So I wonder if this is still valid: https://youtrack.jetbrains.com/issue/KT-51626/Edoardo Luppi
12/15/2023, 2:22 PMbackground
call wrapped in a init$init$
function?Edoardo Luppi
12/15/2023, 3:58 PMEagerInitialization
. Not sure if it's feasibleturansky
12/15/2023, 4:46 PMval init = run {
// your sideeffect
}
turansky
12/15/2023, 4:47 PMEdoardo Luppi
12/15/2023, 4:48 PM