Creates a new instance of the LiveData class
<script src="https://unpkg.com/js-livedata@1.0.2/livedata.min.js"></script>
Creates a new instance of the LiveData class
const data = new LiveData()
Getting instant callback whenever the value are changed
data.observe(v => {
console.log('observe', v)
})
Observing changes in the data object with a debounce mechanism
data.observeDebounce(v => {
console.log('observeDebounce', v)
})
or with your prefered time
data.observeDebounce(v => {
console.log('observeDebounce', v)
}, 1300)
Observing changes in the data object with a throttled mechanism
data.observeThrottle(v => {
console.log('observeThrottle', v)
})
or with your prefered time
data.observeThrottle(v => {
console.log('observeThrottle', v)
}, 1300)
Posts an asynchronous task to a main thread to set the given value.
data.postValue('Hello World!')
You can just post value from an element event
<input type="text" oninput="data.postValue(this.value)" />
Hello World!
Creates a new instance of the LiveValidator class
const validator = new LiveValidator()
// or with defined keys
const validator = new LiveValidator(['username', 'password'])
Getting instant callback whenever the form are valid
validator.observe((validity, map) => {
console.log('validator', validity, map)
})
validator.set('username', someValue != '' && someValue.length >= 8)
You can just set validity from an element event with the key
<input type="text" oninput="validator.set('username', this.value != '')" />
Is it valid?
Form validity value will be here