mirror of
https://github.com/jaandrle/deka-dom-el
synced 2024-11-21 23:39:37 +01:00
♻️ Rename listen
to on
This commit is contained in:
parent
1fbc6a8641
commit
c8bf8dccaf
@ -104,6 +104,6 @@ const value= S("");
|
|||||||
document.body.append(
|
document.body.append(
|
||||||
el("span", { style: { fontWeight: "bold" }, textContent: value }),
|
el("span", { style: { fontWeight: "bold" }, textContent: value }),
|
||||||
el("input", { type: "text" },
|
el("input", { type: "text" },
|
||||||
listen("change", event=> value(event.target.value)))
|
on("change", event=> value(event.target.value)))
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { isSignal } from './signals.js';
|
import { isSignal } from './signals.js';
|
||||||
export function listen(event, listener, options){
|
export function on(event, listener, options){
|
||||||
if(isSignal(event)) return event.listeners.add(listener);
|
if(isSignal(event)) return event.listeners.add(listener);
|
||||||
return element=> element.addEventListener(event, listener, options);
|
return element=> element.addEventListener(event, listener, options);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { S, watch, el, namespace, assign, listen, dispatch } from "../index.js";
|
import { S, watch, el, namespace, assign, on, dispatch } from "../index.js";
|
||||||
Object.assign(globalThis, { S, watch, el, namespace, assign, listen, dispatch });
|
Object.assign(globalThis, { S, watch, el, namespace, assign, on, dispatch });
|
||||||
|
|
||||||
const { style, css }= createStyle();
|
const { style, css }= createStyle();
|
||||||
globalThis.test= console.log;
|
globalThis.test= console.log;
|
||||||
const app= el(component, null, listen("change", globalThis.test));
|
const app= el(component, null, on("change", globalThis.test));
|
||||||
dispatch("change", "Peter")(app);
|
dispatch("change", "Peter")(app);
|
||||||
console.log(app, app instanceof HTMLDivElement);
|
console.log(app, app instanceof HTMLDivElement);
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ function component({ name= "World", surname= "" }= {}){
|
|||||||
`;
|
`;
|
||||||
const store= S({ name, surname });
|
const store= S({ name, surname });
|
||||||
const full_name= S(()=> store.name()+" "+store.surname());
|
const full_name= S(()=> store.name()+" "+store.surname());
|
||||||
listen(full_name, console.log);
|
on(full_name, console.log);
|
||||||
|
|
||||||
return el("div", { className }).append(
|
return el("div", { className }).append(
|
||||||
el("p").append(
|
el("p").append(
|
||||||
@ -34,12 +34,12 @@ function component({ name= "World", surname= "" }= {}){
|
|||||||
el("label").append(
|
el("label").append(
|
||||||
el("#text", { textContent: "Set name:" }),
|
el("#text", { textContent: "Set name:" }),
|
||||||
el("input", { type: "text", value: store.name },
|
el("input", { type: "text", value: store.name },
|
||||||
listen("change", ev=> store.name(ev.target.value))),
|
on("change", ev=> store.name(ev.target.value))),
|
||||||
),
|
),
|
||||||
el("label").append(
|
el("label").append(
|
||||||
el("#text", { textContent: "Set surname:" }),
|
el("#text", { textContent: "Set surname:" }),
|
||||||
el("input", { type: "text", value: store.surname },
|
el("input", { type: "text", value: store.surname },
|
||||||
listen("change", ev=> store.surname(ev.target.value))),
|
on("change", ev=> store.surname(ev.target.value))),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user