https://kotlinlang.org logo
Title
a

Alexjok

05/20/2019, 1:11 PM
Hello, how i can create Kotlin job and start it later?
m

Marko Mitic

05/20/2019, 1:13 PM
Explain the employer that you need time to leave you current job 😄
🤔 2
g

gildor

05/20/2019, 1:17 PM
You can create lazy job using
start
param in launch/async
To start use start() function or join()/await()
a

Alexjok

05/20/2019, 1:45 PM
@gildor something like:
fun startUpdate(): Lazy<Job> {
    return lazy {
        GlobalScope.launch {
            hierachyUpdater.doUpdate()
        }
    }
}
?
g

gildor

05/20/2019, 1:46 PM
No
As I said, there is
start
param in launch/async functions
Check docs of launch/async
a

Alexjok

05/20/2019, 2:03 PM
@gildor thx 🙂
fun startUpdate() = GlobalScope.launch(start = CoroutineStart.LAZY) {
    hierachyUpdater.doUpdate()
}
1
g

gildor

05/20/2019, 11:27 PM
Yes, this is what I meant. But I wouldn't use GlobalScope