nrgy
Version:
The library for reactive programming using efficient computing and MVC/MVVM patterns
38 lines (34 loc) • 1.04 kB
text/typescript
import { Observable } from 'rxjs';
import { A as Atom, D as DestroyableAtom, S as Signal } from './types-CxOJPpKX.cjs';
import { S as SignalObserveOptions } from './observe-C5r3qKaO.cjs';
/**
* Provider for a value of a state.
*/
type Query<T> = Readonly<{
/** Returns the value of a state */
get: () => T;
/** `Observable` for value changes. */
value$: Observable<T>;
}>;
/**
* Creates a Query for the given Atom
*/
declare function toQuery<T>(source: Atom<T>): Query<T>;
/**
* Creates an Atom from a Query
*/
declare function fromQuery<T>(query: Query<T>): DestroyableAtom<T>;
/**
* Action of Rx-Effects
*/
type Action<Event> = {
readonly event$: Observable<Event>;
(event: Event): void;
} & ([Event] extends [undefined | void] ? {
(event?: Event): void;
} : {
(event: Event): void;
});
declare function toAction<T>(source: Signal<T>, options?: SignalObserveOptions): Action<T>;
declare function fromAction<T>(action: Action<T>): Signal<T>;
export { fromAction, fromQuery, toAction, toQuery };