snippets
- introduction
- copy text with selector
- copy text via a selector with messaging
- copy with quick copy
- debounce a signal
- forward an element as a sender
- get random numbers
- load data from a url
- load templates from a url
- map a key to a signal
- match elements from parent
- measure performance
- poll data
- receive multiple signals
- render an svg
- run an init function
- send and receive from the same element
- send multiple signals at the same time
- send to multiple receivers
- shuffle an array
- style SVGs
- switch
- switch with init
- update the content of an element
- use a template from the page
- use an alternate listener
- use innerHTML as a number
receive multiple signals
waiting
- A single
data-relement can receive signals from multipledata-ssenders with a space separated list of the signal names to respond to.
html
<div data-r="alfa bravo charlie">waiting</div>
<button data-s="alfa">alfa</button>
<button data-s="bravo">bravo</button>
<button data-s="charlie">charlie</button>javascript
export const b = {};
export function alfa(_, __, el) {
el.innerHTML = "alfa";
}
export function bravo(_, __, el) {
el.innerHTML = "bravo";
}
export function charlie(_, __, el) {
el.innerHTML = "charlie";
}