Internal events helper functions #2358
Unanswered
michaelwarren1106
asked this question in
Ideas
Replies: 1 comment 2 replies
-
This might be interesting related research: whatwg/dom#331 (comment) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With a previous design system that I worked on, one way we used to communicate between parent/child components was to pass internal-only events back up to the parent. I've found that the
slotchange
event or aMutationObserver
works a lot of the time in the parent for doing recalculation of child elements in a parent, but there might be some times those wouldnt be the best idea, or would be too much code, etc. So we came up with a few helper functions that would enable events to be emitted between components that would be "internal only". Basically that the event name would start with a prefix marking them as internal, and through the use of helper functions, enable other components to easily create event listeners for "internal only" events with only the actual event name showing up in the source code. The actual internal event name emitted and listened for would be in memory.The helper functions would be something like:
usage might be something like:
and in a parent component
Its a pretty simple/straight forward set of helpers that would enable cross-component communication in places where
slotchange
andMutationObserver
aren't the right choice?What is this group's thoughts about providing such helpers for a pattern like this as a part of some open-wc package?
Beta Was this translation helpful? Give feedback.
All reactions