CorourtineScope returns null
See original GitHub issueWhen using coroutines for making network calls, I encountered that
private var viewModelJob = Job()
private val coroutineScope: CoroutineScope = CoroutineScope(viewModelJob + Dispatchers.Main)
private fun getMarsRealEstateProperties() {
if (coroutineScope == null) {
Log.d("TAG_TAG", "NULL")
}
}
At first when using coroutineScope.launch {…}, it throws
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter receiver$0
Is this a bug or some problem on my side?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
Kotlin coroutine list returning null value - Stack Overflow
I would suggest using LivaData to observe data: class MyViewModel : ViewModel() { val listado: LiveData<String> = MutableLiveData<String>() ...
Read more >CoroutineScope - Kotlin
Defines a scope for new coroutines. Every coroutine builder (like launch, async, etc.) is an extension on CoroutineScope and inherits its coroutineContext ...
Read more >Return value from coroutines - CommonsWare
For a method that has coroutine scope that does work in the back ground, ... searchTeamEvents(“TeamName”) it still returns the empty string.
Read more >Android Coroutine Recipes. Table of Contents - ProAndroidDev
Background job is executed via withContext function with the IO dispatcher. val uiScope = CoroutineScope(Dispatchers.Main)fun loadData() = uiScope.launch { view ...
Read more >Kotlin Coroutine Job Lifecycle - Marco Cattaneo
Coroutine Scope : what's its lifecycle and the behavior of jobs. ... Parent Job: the parent Job of children jobs, by default is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
you must create your job and coroutineScope before the init block.
It solved my problem, but can u explain what was the problem