import { type NonEmptyArray } from 'ts-type-forge'; import { type MergeObservableRefined, type Observable } from '../types/index.mjs'; /** * Merges multiple observables into a single observable that emits all values from all sources. * Emits whenever any source observable emits a value. * * @template OS - Tuple type of source observables * @param parents - Array of observables to merge * @returns A merged observable emitting values from any source * * @example * ```ts * // Timeline: * // * // clicks$ c1 c2 c3 * // keys$ k1 k2 k3 * // events$ c1 k1 c2 k2 c3 k3 * // * // Explanation: * // - merge combines multiple observables into one * // - Emits values from any source as they arrive * // - Order is preserved based on emission time * * const clicks$ = source(); * * const keys$ = source(); * * const events$ = merge([clicks$, keys$]); * * const valueHistory: string[] = []; * * events$.subscribe((event_) => { * valueHistory.push(event_); * }); * * clicks$.next('c1'); * * assert.deepStrictEqual(valueHistory, ['c1']); * * keys$.next('k1'); * * assert.deepStrictEqual(valueHistory, ['c1', 'k1']); * * clicks$.next('c2'); * * keys$.next('k2'); * * assert.deepStrictEqual(valueHistory, ['c1', 'k1', 'c2', 'k2']); * ``` * * @note To improve code readability, consider using `createState` instead of `merge`, * subscribing to `parents` and calling `setState` within it. */ export declare const merge: >>(parents: OS) => MergeObservableRefined; //# sourceMappingURL=merge.d.mts.map