UNPKG

@guanghechen/react-viewmodel

Version:
21 lines (14 loc) 1.27 kB
import { IComputed, IImmutableCollection, IObservableCollection, IViewModel, IObservableKey, IState } from '@guanghechen/viewmodel'; export * from '@guanghechen/viewmodel'; declare function useComputed<T>(computed$: IComputed<T>): T; declare function useObserveKey<K, V, C extends IImmutableCollection<K, V>>(collection: IObservableCollection<K, V, C>, key: K): V | undefined; declare function useObserveSignal<M extends IViewModel, K extends IObservableKey<M>>(viewmodel: M, keys: K[]): number; type ISetState<T> = (patch: (prev: T) => T) => void; type IUpdateState<T> = T | ISetState<T>; declare function useStateValue<T>(state$: IState<T>): T; declare function useSetState<T>(state$: IState<T>): ISetState<T>; declare function useState<T>(state$: IState<T>): [T, ISetState<T>]; declare function useReactState<T>(state$: IState<T>): [T, IUpdateState<T>]; declare function useToggleState(state$: IState<boolean>): () => void; declare const useSyncExternalStore: <T>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T) => T; export { type ISetState, type IUpdateState, useComputed, useObserveKey, useObserveSignal, useReactState, useSetState, useState, useStateValue, useSyncExternalStore, useToggleState };