Object become a null after I put it in coroutine

Viewed 38

I want to store my state in repository and do in acynchronously. Here I preparing my state and putting it in coroutine.

fun saveState(state: MapState) {
    viewModelScope.launch {
        withContext(Dispatchers.IO) {
            mapRepository.saveState(state, mapRepository.defaultStateId)
        }
    }
}

But already in next function "saveState" I found, that my object "mOutline" in "MapState" became null. Object before putting in coroutine Object after putting in coroutine And after all I get NullPointerExeption when trying to handle object. I tryed this code without coroutine and it worked well. Maybe I do something wrong with coroutine? There is my project on GitHub https://github.com/Panicia/Wegitantion_index_counter/tree/master/app/src/main/java/viewModels/mapViewModel

0 Answers
Related