package.src.magics.$watch.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alpinejs Show documentation
Show all versions of alpinejs Show documentation
The rugged, minimal JavaScript framework
import { magic } from '../magics'
import { watch } from '../reactivity'
magic('watch', (el, { evaluateLater, cleanup }) => (key, callback) => {
let evaluate = evaluateLater(key)
let getter = () => {
let value
evaluate(i => value = i)
return value
}
let unwatch = watch(getter, callback)
cleanup(unwatch)
})