yewstack / yewstack/yew

Ergonomic pattern for passing along on* callbacks to children

Open
#1,533 18 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-yew-macro feature-request
Dominant language
Rust
Stars
32.8k
Forks
1.5k
Avg merge
5h 34m
Merged PRs (30d)
2

Description

Describe the feature you'd like
I am in the process of creating a Bulma component library for Yew. For many of the components, users will need to attached callback handlers to respond to events. There are A LOT of different event types, and I'm looking for a way to be able to collect any on* event handlers attached to the component, and pass them down to the component's concrete HTML elements (where the DOM events actually take place).

Is your feature request related to a problem? Please describe. (Optional)
The problem is that I would have to create a very large amount of code on almost all of the components to be able to pass along these on* event handlers. Not impossible ... but definitely seems like an anti-pattern.

Describe alternatives you've considered (Optional)
I've looked into using https://github.com/deniskolodin/mixin, but the need for a generic type parameter seems to be causing issues with that approach.

Questionnaire

  • I'm interested in implementing this myself but don't know where to start
  • I would like to add this feature
  • I don't have time to add this right now, but maybe later

On that last note, if there is no straightforward way to handle this in Yew right now ... I'll probably just postpone the development of the component library :). It is primarily for a personal project, so I can move forward without finishing things.

Either way, I would love to implement this capability in Yew, just need to hear from those of you that know the code base the best on what design options we have here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are identified in the issue. Start by tracing Yew's existing on* event-handler and child-component APIs, then compare design options for forwarding handlers to concrete HTML elements. Done means a workable pattern supports the required event types without repetitive per-component code.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.