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

Allow setting the onevent callback per-call for m.redraw #2074

Closed
dead-claudia opened this issue Jan 10, 2018 · 3 comments · Fixed by #2458
Closed

Allow setting the onevent callback per-call for m.redraw #2074

dead-claudia opened this issue Jan 10, 2018 · 3 comments · Fixed by #2458
Labels
Type: Enhancement For any feature request or suggestion that isn't a bug fix
Milestone

Comments

@dead-claudia
Copy link
Member

dead-claudia commented Jan 10, 2018

(Elevating this comment into an issue)

I could use the ability to set per-call the onevent callback for custom auto-redraw behavior on nodes rendered in that call only.

Also, that option could be used by redrawService to avoid needing the setEventCallback API in the first place, making it a little easier to integrate the two.

Note: this option would change vnode.events objects accordingly if onevent was already set for it.

(Yes, this implies a slight memory increase for vnodes with event handlers, but I doubt perf implications would be significant at all, since the event objects are persisted across redraws anyways.)

@dead-claudia dead-claudia changed the title Offer primitives for custom auto-redraw hooks Allow setting the onevent callback per-call for m.redraw Jan 10, 2018
@dead-claudia
Copy link
Member Author

dead-claudia commented Jan 10, 2018

This is all I need to integrate my SelfSufficient helper (a userland implementation of subtree redrawing) into Mithril's autoredraw system (and nullify the need for one of my existing API methods).


Side note: I'm relying on a few internals in that to actually do it right:

  • vnode.dom, vnode.domSize, vnode.state, and vnode.events are all copied.
  • I also have to manage vnode.instance directly on explicit redraw, so Mithril diffs against the most recent tree.

Also, I had to reimplement the following (amounting to ~30% of the code):

@dead-claudia dead-claudia added this to the 2.0.0 milestone Jan 17, 2018
@tivac tivac modified the milestones: 2.0.0, post-v2 Apr 24, 2018
@dead-claudia dead-claudia added the Type: Enhancement For any feature request or suggestion that isn't a bug fix label Oct 28, 2018
@dead-claudia dead-claudia added this to Under consideration in Feature requests/Suggestions via automation Oct 28, 2018
@dead-claudia
Copy link
Member Author

dead-claudia commented Nov 5, 2018

One other thing I'd do as part of this is move the e.redraw checks to m.render itself instead of doing it in m.mount. This simplifies both m.mount and user onevent implementations and it saves a few bytes in the process.

@dead-claudia
Copy link
Member Author

And one last thing: I would add a final render argument to oninit* and constructors so they don't have to depend on the global redraw instance.

* Only if we decide to keep stateful object components. (This was discussed on Gitter and referenced in #2293.)

@dead-claudia dead-claudia moved this from Under consideration to In discussion in Feature requests/Suggestions Jan 2, 2019
@dead-claudia dead-claudia mentioned this issue Jul 7, 2019
11 tasks
Feature requests/Suggestions automation moved this from In discussion to Completed/Declined Jul 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement For any feature request or suggestion that isn't a bug fix
Projects
Development

Successfully merging a pull request may close this issue.

2 participants