You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The naming of the coroutine scope associated with a ScreenModel has tripped me up a few times when writing and reading code in Voyager:
The name is already heavily overloaded as is: The coroutineScopefunction as well as the CoroutineScopebuilder are often used in concurrent code, so having another symbol also called coroutineScope that has different semantics can be confusing:
// ...
coroutineScope.launch {
// uses the screenModel's scope
}
coroutineScope {
launch {
// uses the `coroutineScope` suspending function
}
}
The current name carries no information about the lifetime or association of the scope. Compare this to Android's viewModelScope (the scope associated with the ViewModel and its lifecycle), or Ktor's Application and Pipeline-associated coroutine scopes (associated with the lifetime of the application and individual request handlers).
As such, I think it would be much clearer if the coroutine scope associated with a screen would be named screenModelScope or similar.
The text was updated successfully, but these errors were encountered:
The naming of the coroutine scope associated with a
ScreenModel
has tripped me up a few times when writing and reading code in Voyager:coroutineScope
function as well as theCoroutineScope
builder are often used in concurrent code, so having another symbol also calledcoroutineScope
that has different semantics can be confusing:viewModelScope
(the scope associated with the ViewModel and its lifecycle), or Ktor'sApplication
andPipeline
-associated coroutine scopes (associated with the lifetime of the application and individual request handlers).As such, I think it would be much clearer if the coroutine scope associated with a screen would be named
screenModelScope
or similar.The text was updated successfully, but these errors were encountered: