mirror of
https://github.com/jaandrle/deka-dom-el
synced 2025-07-01 12:22:15 +02:00
⚡ Docs
This commit is contained in:
18
docs/components/examples/scopes/good-practise.js
Normal file
18
docs/components/examples/scopes/good-practise.js
Normal file
@ -0,0 +1,18 @@
|
||||
import { el, scope, on, dispatchEvent } from "deka-dom-el";
|
||||
document.body.append(
|
||||
el(component)
|
||||
);
|
||||
function component(){
|
||||
const { host }= scope; // good practise!
|
||||
|
||||
host(
|
||||
console.log,
|
||||
on("click", function redispatch(){
|
||||
// this `host` ↘ still corresponds to the host ↖ of the component
|
||||
dispatchEvent("redispatch")(host());
|
||||
})
|
||||
);
|
||||
// this `host` ↘ still corresponds to the host ↖ of the component
|
||||
setTimeout(()=> dispatchEvent("timeout")(host()), 750)
|
||||
return el("p", "Clickable paragraph!");
|
||||
}
|
Reference in New Issue
Block a user