UNPKG

@ts-livedata/react

Version:
24 lines (23 loc) 767 B
import { LiveData, Observer } from "@ts-livedata/core"; /** * React Hook LiveData (similar to {@link MutableLiveData}) which removes observers automatically once unmounted. */ declare class HookLiveData<T> extends LiveData<T> { /** * Attaches and detaches Observer to React functional component. * * @remarks * Should be used within scope of React Hooks, not {@link React.Component}. * Otherwise runtime error will be thrown from React. * * @param observer The observer to watch for changes. */ observe(observer: Observer<T>): void; /** * Sets current LiveData value, and notifies observers. * * @param value The value to set. */ postValue(value: T): void; } export default HookLiveData;