Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename coroutineScope to screenModelScope #227

Closed
SebastianAigner opened this issue Oct 4, 2023 · 0 comments
Closed

Rename coroutineScope to screenModelScope #227

SebastianAigner opened this issue Oct 4, 2023 · 0 comments

Comments

@SebastianAigner
Copy link

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 coroutineScope function as well as the CoroutineScope builder 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants