Skip to content

Commit

Permalink
Expose CoroutineScope as viewModelScope
Browse files Browse the repository at this point in the history
  • Loading branch information
dcvz committed Apr 16, 2022
1 parent b154c81 commit 5604b99
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.doublesymmetry.viewmodel

import androidx.lifecycle.ViewModel as AndroidXViewModel
import androidx.lifecycle.viewModelScope
import androidx.lifecycle.viewModelScope as androidXViewModelScope

actual open class ViewModel : AndroidXViewModel() {
actual val scope = viewModelScope
actual val viewModelScope = androidXViewModelScope
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.doublesymmetry.viewmodel

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlin.coroutines.CoroutineContext

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ actual open class ViewModel {
private val lock = reentrantLock()
private var backingScope: CoroutineScope? = null

actual val scope: CoroutineScope
actual val viewModelScope: CoroutineScope
get() {
return this.getScopeInstance() ?: this.createScopeInstance()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package com.doublesymmetry.viewmodel
import kotlinx.coroutines.CoroutineScope

expect open class ViewModel() {
val scope: CoroutineScope
val viewModelScope: CoroutineScope
}

0 comments on commit 5604b99

Please sign in to comment.