-
Notifications
You must be signed in to change notification settings - Fork 49
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
lifecycle hooks #30
Comments
I want to play around with how this will affect the ecosystem but I'm thinking we should implement as custom events for consistency with existing events: var popover = bel`<div onload=${function () {
document.addEventListener('mousedown', isMouseOutside, false)
}} onunload=${function () {
document.removeEventListener('mousedown', isMouseOutside, false)
}}>hi</div>`
// Fire onload
document.body.appendChild(popover)
// Fire onunload
document.body.removeChild(popover) I only chose the names Also atm I just want to stick with these two events. Each framework has an analog to these two, so when implementing interoperability later it will make it easy if we don't add any more custom events like |
ooh, yeah I really like that - means that there's no overhead unless explicitly opted in to. Might perhaps need some work with Yeah, also think that sticking to these two events would be good. Might be worth considering to pass the enclosing element as the first argument to the callback for |
@yoshuawuyts the first time I read your comment, I thought you meant pass the parent element (misread "enclosing"). Reading it again, I think you meant the element itself (that probably makes more sense anyway). Right? return bel`<div class="map" onload=${(el) => L.map(el)}></div>` Because without a reference to it, you'd have to memoize the element, which could get a bit tedious. Unless |
@timwis yup, you got that right - apologies for not being clear enough |
Add onload/onunload lifecycle properties. Fixes GH-30
As per our twitter convo we should probably investigate the possibilities of adding lifecycle hooks to
yo-yo
/bel
again ✨The text was updated successfully, but these errors were encountered: