UNPKG

3.42 kBTypeScriptView Raw
1import "./map";
2import Observable from "./observable";
3import { Property } from "./observable";
4import { Function0, Function1, Function2, Function3, Function4, Function5, Function6 } from "./types";
5/**
6 Combines Properties, EventStreams and constant values so that the result Property will have an array of the latest
7 values from all sources as its value. The inputs may contain both Properties and EventStreams.
8
9
10 ```js
11 property = Bacon.constant(1)
12 stream = Bacon.once(2)
13 constant = 3
14 Bacon.combineAsArray(property, stream, constant)
15 # produces the value [1,2,3]
16 ```
17
18 * @param streams streams and properties to combine
19 */
20export declare function combineAsArray<V>(...streams: (Observable<V> | Observable<V>[])[]): Property<V[]>;
21/**
22 Combines given *n* Properties and
23 EventStreams using the given n-ary function `f(v1, v2 ...)`.
24
25 To calculate the current sum of three numeric Properties, you can do
26
27```js
28function sum3(x,y,z) { return x + y + z }
29Bacon.combineWith(sum3, p1, p2, p3)
30```
31*/
32export declare function combineWith<R>(fn: Function0<R>): Property<R>;
33export declare function combineWith<V, R>(a: Observable<V>, fn: Function1<V, R>): Property<R>;
34export declare function combineWith<V, V2, R>(a: Observable<V>, b: Observable<V2>, fn: Function2<V, V2, R>): Property<R>;
35export declare function combineWith<V, V2, V3, R>(a: Observable<V>, b: Observable<V2>, c: Observable<V3>, fn: Function3<V, V2, V3, R>): Property<R>;
36export declare function combineWith<V, V2, V3, V4, R>(a: Observable<V>, b: Observable<V2>, c: Observable<V3>, d: Observable<V4>, fn: Function4<V, V2, V3, V4, R>): Property<R>;
37export declare function combineWith<V, V2, V3, V4, V5, R>(a: Observable<V>, b: Observable<V2>, c: Observable<V3>, d: Observable<V4>, e: Observable<V5>, fn: Function5<V, V2, V3, V4, V5, R>): Property<R>;
38export declare function combineWith<V, V2, V3, V4, V5, V6, R>(a: Observable<V>, b: Observable<V2>, c: Observable<V3>, d: Observable<V4>, e: Observable<V5>, f: Observable<V6>, fn: Function6<V, V2, V3, V4, V5, V6, R>): Property<R>;
39export declare function combineWith<R>(observables: Observable<any>[], fn: Function): Property<R>;
40export declare function combineWith<V, R>(fn: Function1<V, R>, a: Observable<V>): Property<R>;
41export declare function combineWith<V, V2, R>(fn: Function2<V, V2, R>, a: Observable<V>, b: Observable<V2>): Property<R>;
42export declare function combineWith<V, V2, V3, R>(fn: Function3<V, V2, V3, R>, a: Observable<V>, b: Observable<V2>, c: Observable<V3>): Property<R>;
43export declare function combineWith<V, V2, V3, V4, R>(fn: Function4<V, V2, V3, V4, R>, a: Observable<V>, b: Observable<V2>, c: Observable<V3>, d: Observable<V4>): Property<R>;
44export declare function combineWith<V, V2, V3, V4, V5, R>(fn: Function5<V, V2, V3, V4, V5, R>, a: Observable<V>, b: Observable<V2>, c: Observable<V3>, d: Observable<V4>, e: Observable<V5>): Property<R>;
45export declare function combineWith<V, V2, V3, V4, V5, V6, R>(fn: Function6<V, V2, V3, V4, V5, V6, R>, a: Observable<V>, b: Observable<V2>, c: Observable<V3>, d: Observable<V4>, e: Observable<V5>, f: Observable<V6>): Property<R>;
46export declare function combineWith<R>(fn: Function, observables: Observable<any>[]): Property<R>;
47export declare const combine: typeof combineWith;
48/** @hidden */
49export declare function combineTwo<V, V2, R>(left: Observable<V>, right: Observable<V2>, f: Function2<V, V2, R>): Property<R>;