@ts-livedata/core
v1.0.1-alpha01
Published
A TypeScript LiveData library.
Maintainers
Readme
TS LiveData Library
About
Observer pattern based library for TypeScript, similar to Android's LiveData.
For information on the Observer pattern please visit Wikipedia.
Installation
npm install @ts-livedata/coreyarn add @ts-livedata/coreUsage
import {MutableLiveData, Observer} from "@ts-livedata/core"
const liveData = new MutableLiveData<String | null>()
const observer: Observer<String | null> = (value => {
if (value) {
console.log(`your value: ${value}`)
} else {
console.log(`null value`)
}
})
// Can observer before or after posting a value
liveData.observe(observer)
liveData.postValue("TypeScript LiveData")
// When you're ready to stop listening for changes
liveData.removeObserver(observer)
// Or you can remove all observers via
liveData.removeAllObservers()Questions
Feel free to drop a Github issue with any questions you may have.
License
This project is licensed under the terms of the Apache 2.0 license.
