Last active
February 11, 2021 03:33
-
-
Save UpperCod/df54b2c50eacfea493c359582b15da70 to your computer and use it in GitHub Desktop.
Reative properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { c } from "atomico; | |
function component() { | |
return <host></host>; | |
} | |
component.props = { | |
value: String, | |
checked: { | |
type: Boolean, | |
reflect: true, | |
value : false, | |
event: { type: "change", bubbles: true, composed: true }, | |
}, | |
}; | |
customElements.define("my-component", c(component)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myComponent = document.querySelector("my-component"); | |
myComponent.addEventListener("change", ({ target }) => { | |
console.log(target.checked); | |
}); | |
// Changes are added to the queue | |
// update of the webcomponent | |
myComponent.value = "next value"; | |
myComponent.checked = "next value"; | |
// to read the changes from the DOM we | |
// must wait for the updated promise to finish | |
myComponent.updated.then(() => { | |
console.log("dom update"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment