Skip to content

HandlerDispatcher name #580

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

Closed
Uiasdnmb opened this issue Sep 18, 2018 · 5 comments
Closed

HandlerDispatcher name #580

Uiasdnmb opened this issue Sep 18, 2018 · 5 comments

Comments

@Uiasdnmb
Copy link

I've updated to 0.26.0 recently and noticed that HandlerContext(handler, name) is deprecated.

If I understand correctly, it should be replaced with Handler.asCoroutineDispatcher(). However this doesn't provide the name argument which I need for debugging, so I'm forced to use "deprecated" constructor.

@elizarov
Copy link
Contributor

HandlerContext was renamed to HandlerDispatcher and now Handler.asCoroutineDispatcher returns (non-deprecated) HandleDispatcher. Can you please clarify what problem do you have?

@Uiasdnmb
Copy link
Author

Sorry if it wasn't clear. Is inability to specify custom name intentional? Just a little inconvenience but it makes using toString() for logging a bit harder.

@elizarov
Copy link
Contributor

I see. No it was not intentional. I'll leave it open as a change request.

@elizarov
Copy link
Contributor

@Uiasdnmb can you, please, clarify what different HandlerDispatcher implementations you are using in your code? What is your use-case? Shall we just include Handler.toString into the string representation of the CoroutineDispatcher that is produced by handler.asCoroutineDispatcher()?

@Uiasdnmb
Copy link
Author

From source I see it already does use Handler.toString as fallback in case of name being null.

But it does impose the need of subclassing the handler with custom toString before using asCoroutineDispatcher.

I have a "loader" framework based on coroutines that uses HandlerContext to return results on UI thread, but each loader has its own HandlerContext instance so name is rather handy in printing.

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

No branches or pull requests

2 participants