v0.5.0 - createEffect
The createEffect
function is a way to manage side effects. It uses the MutationObserver
API internally. The dependency array accepts a string of id
s corresponding to their DOM element(s).
If the dependency array is empty, the callback runs only once (since the app is rendered only once).
createEffect(() => {
console.log("Hello, World!");
}, [])
If the dependency array is not empty, the callback runs every time there is a change in a corresponding element or child of an element.
...
const [count, setCount] = createState(0);
createEffect(() => {
console.log("Update value of count: ", count().value);
}, [count().key])
...
Full Changelog: v0.4.0...v0.5.0