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

OnMessage trait #257

Closed
wants to merge 5 commits into from
Closed

OnMessage trait #257

wants to merge 5 commits into from

Conversation

dhardy
Copy link
Collaborator

@dhardy dhardy commented Nov 5, 2021

There are a couple of challenges with the existing per-child-widget message handler system:

  • binding the same handler to multiple children is tedious
  • binding handlers to generic parent widgets such as List cannot work in the same way

Instead, this attempts to bind handlers based on the message type by requiring parent widgets implement a new OnMessage trait. But first we need a couple of auto-implementations:

  • children with VoidMsg message type should be supported automatically
  • children with the same message type as the parent should automatically forward the message

Problem: these generic implementations overlap. Except: we already worked around this via derive(VoidMsg): each viable message type supports From<VoidMsg>, thus we can implement a rule for any M: From<N> where M and N are the parent's and child's message types respectively.

Problem: implementing a specific handler which is not covered by the above rule is now reported as a conflict: rust-lang/rust#90587. This blocks further progress here.

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

1 participant