" (compare for example with ",el("a",{textContent:"fpubsub library",href:"https://www.npmjs.com/package/fpubsub",title:"NPM package: fpubsub"}),").",
" All three parts can be in some manner independent and still connected",
" to the same reactive entity."
),
el("p",{className:"notice"}).append(
"The other difference is that there is ",el("strong","no")," ",el("code","off")," function.",
" ",
"You can remove listener declaratively using ",el("a",{textContent:"AbortSignal",href:"https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#signal",title:"part of addEventListener on MDN"}),
":"
el("p").append(
"Signals are implemented in the library as functions. To see current value",
" of signal, just call it without any arguments ",el("code","console.log(signal())"),".",
" To update the signal value, pass any argument ",el("code","signal('a new value')"),".",
" For listenning the signal value changes, use ",el("code","S.on(signal, console.log)"),"."
el("li").append(el("code",`el("button", { textContent: "click me" }, on("click", console.log))`))
),
el("p").append(
"In the first example we force to use HTML attribute (it corresponds to ",el("code",`<button onclick="console.log(event)">click me</button>`),").",
" ",
el("em","Side note: this can be useful in case of SSR."),
" ",
"To study difference, you can read a nice summary here: ",el("a",{href:"https://gist.github.com/WebReflection/b404c36f46371e3b1173bf5492acc944",textContent:"GIST @WebReflection/web_events.md"}),"."
"For Custom elements, we will later introduce a way to replace ",el("code","*Callback"),
" syntax with ",el("code","dde:*")," events. The ",el("code","on.*")," functions then",
" listen to the appropriate Custom Elements events (see ",el("a",{textContent:"Custom element lifecycle callbacks | MDN",href:"https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#custom_element_lifecycle_callbacks"}),")."
),
el("p").append(
"But, in case of regular elemnets the ",el("a",{href:"https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver"}).append(el("code","MutationObserver")," | MDN"),
" is internaly used to track these events. Therefore, there are some drawbacks:",
),
el("ul").append(
el("li").append(
"To proper listener registration, you need to use ",el("code","on.*")," not `on(\"dde:*\", …)`!"
),
el("li").append(
"Use sparingly! Internally, library must loop of all registered events and fires event properly.",
" ",
el("strong","It is good practice to use the fact that if an element is removed, its children are also removed!"),
" ",
"In this spirit, we will introduce later the ",el("strong","host")," syntax to register",
" clean up procedures when the component is removed from the app."
),
),
el(h3,"Final notes"),
el("p","The library also provides amethod to dispatch the events."),
{id:"p02-elements",href:"p02-elements",title:"Elements",description:"Basic concepts of elements modifications and creations."},
{id:"p03-events",href:"p03-events",title:"Events and Addons",description:"Using not only events in UI declaratively."},
{id:"p04-signals",href:"p04-signals",title:"Signals and reactivity",description:"Handling reactivity in UI via signals."},
];
/**
* @typedef registerClientFile
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.