Hello all, I am new at kotlin, Is this the correc...
# coroutines
Hello all, I am new at kotlin, Is this the correct way that the flow is executed?
Copy code
suspend fun Logout(token: String) {
    val userId = appService.currentUser!!.id       ///// this will execute 1st
    realm.write {                                  ///// this will execute 2nd
        var user = query<UserInfo>("_id = $0", userId).first().find()
        if (user != null) {
            user = findLatest(user)!!.also {
    withContext(Dispatchers.Default) {             ///// this will execute 3rd

        realm.syncSession.uploadAllLocalChanges()  ///// this will execute 4rd

        appService.currentUser?.logOut()           ///// this will execute 5th
Are they executed in a linear way?
Yup, they execute sequentially, one won't start after the previous one has finished.
Just watch out which scope this is called in. You don’t want your logout being canceled if .e.g on android your view model goes away.
well, this isn't transactional even if you use
(what if the app is killed?), so you have some way of recovering from interruptions regardless
true, but logging out in a scope that regularly gets canceled right after it’s started should still be avoided 😉