be-channeling is a web component / decorator / behavior / custom attribute. It responds to internal events of the component it adorns.
npm install be-channeling
html
>
`
Alternative syntax [TODO]
`html
>
`
... means "If the triggering element is a button, then call myHostMethod from the host".
> Isn't this a violation of encapsulation, to be monitoring for events that are coming from inside the (Shadow DOM) children of an element?
Not really. As we can see in this example, the button element is part of the light children used to define the template that xtal-vlist uses.
The example above is basically the simplest example, but the syntax can scale to much larger scenarios:
1. If more than one event type to monitor for, use an array.
2. The eventFilter can be an object, and allows for more complex event filtering.
For example:
`html
`
No, not JSON!
The json-in-html VSCode plugin allows us to benefit from syntax color highlighting, and consequently avoid most syntax misfires, including while editing README files. It is compatible with the web versions of VSCode.
In addition, the may-it-be transpiler allows us to edit .mts/.mjs files, and it compiles the files to static HTML files, which is another way to escape the purgatory that is raw JSON editing. Using this technique, we can benefit from type checks on our attributes with no additional IDE plugins, and avoid all the non-ergonomic typing of quotes, and escaping.
Alternatively [TODO]
`html
`
Viewing Locally
1. Install git.
2. Fork/clone this repo.
3. Install node.
4. Open command window to folder where you cloned this repo.
5. > npm install
6. > npm run serve
7. Open http://localhost:3030/demo/dev in a modern browser.
Importing in ES Modules:
`JavaScript
import 'be-channeling/be-channeling.js';
`
Using from CDN:
`html
``