UNPKG

@promptbook/vercel

Version:

Promptbook: Turn your company's scattered knowledge into AI ready books

20 lines (19 loc) 814 B
import { BehaviorSubject } from 'rxjs'; /** * A type that represents a value that can be updated over time: * * 1) It can be a static value of type `TValue` * 2) Or a `BehaviorSubject` that emits values of type `TValue` * 3) Or pair of `[getValue, setValue]` functions for getting and setting the value */ export type Updatable<TValue> = TValue | BehaviorSubject<TValue> | [TValue, (value: TValue) => void]; /** * Restricts an Updatable to a (2) BehaviorSubject variant * * @see Updatable * @private internal utility <- TODO: [🧠] Maybe export from `@promptbook/types` */ export declare function asUpdatableSubject<TValue>(value: Updatable<TValue>): BehaviorSubject<TValue>; /** * TODO: [🧠] Maybe `BehaviorSubject` is too heavy for this use case, maybe just tuple `[value,setValue]` is enough */