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

Support passing CoroutineContext to any CoroutineDispatcher methods. #2241

Merged
merged 3 commits into from
May 9, 2024

Conversation

colinrtwhite
Copy link
Member

No description provided.

*
* Default: `Dispatchers.Main.immediate`
*/
fun interceptorDispatcher(dispatcher: CoroutineDispatcher) = apply {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jingibus Do you think it's worth renaming these to interceptorContext, etc.? Is there a naming pattern we've followed in other libraries?

I'm leaning towards keeping the names as is since they're more discoverable and in 90% of cases users only want to set the dispatcher.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have strong opinions about it. In Cash's codebase, we tend to use dispatcher for the injected val.

This API change might be cause to modify how the defaults work, too: it is possible that you want EmptyCoroutineContext or any context without a dispatcher to also default to Dispatchers.Main.immediate? Or would it be appropriate for EmptyCoroutineContext to mean what it does in other contexts: "use whatever dispatcher you're already on"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Sounds good. I'll leave the names as is for the moment.

For the defaults I think we want to leave them as is too. They're opinionated (for instance, we almost always want to fetch on a background dispatcher), but will work in any context.

@colinrtwhite colinrtwhite merged commit b98463f into main May 9, 2024
8 checks passed
@colinrtwhite colinrtwhite deleted the colin/coroutine_context branch May 9, 2024 18:26
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

Successfully merging this pull request may close these issues.

None yet

2 participants