Optional messages for advanced events#366
Conversation
this comes in handy when you need to stop a lot of events from propagating. Also improved the advanced API with `evend.send` and `event.retain` which helps reduce boilerplate.
|
Hey there! I appreciate it takes a little bit of time to put PRs like this together so first of all thank you for opening this. For now I will have to reject this PR however, for a couple of reasons:
This PR wasn't opened in a vacuum so let me also make some general observations around the thread on discord. You discuss use of native HTML dialog elements and needing to stop propagation of key events when the dialog is open. The behaviour you want already exists in the platform by way of modal dialogs:
I suspect you are currently toggling the dialog's visibility using the To do this in Lustre I would write a small effect that queries the DOM for the dialog you want to open and then invokes this method, perhaps: fn open_modal(selector: String) -> Effect(msg) {
use _, _ <- effect.before_paint
do_open_modal(selector)
}
@external(javascript, "./ffi.mjs", "open_modal")
fn do_open_modal(selector: String) -> Nilexport const open_modal = selector => {
const element = document.querySelector(element)
if (element instanceof HTMLDialogElement) {
element.showModal()
}
}I hope this gets you on the right path, it sounds like exactly what you need! Thank you again for taking the time to open a PR; interest in improving the project is always exciting 💕 |
this comes in handy when you need to stop a lot of events from propagating. Also improved the advanced API with
evend.sendandevent.retainwhich helps reduce boilerplate. Think about a Dialogs component which needs to stop a lot of events from propagating. This also triggers a lot of necessarylustre.viewcalls.Example: