Created
February 22, 2021 20:38
-
-
Save le0nidas/90244297fd7347c5e48555ca68abe3b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun saveUserTasks(userId: Int, state: State) { | |
when (state.label) { | |
0 -> { | |
val user = loadUser(userId) | |
println("user loaded") | |
state.result = user | |
state.label = 1 | |
return | |
} | |
1 -> { | |
// resume execution | |
val user = state.result as User | |
val tasks = loadTasks(user) | |
println("tasks loaded") | |
state.result = tasks | |
state.label = 2 | |
return | |
} | |
2 -> { | |
// resume execution | |
val tasks = state.result as List<Task> | |
saveTasks(tasks) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment