forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
baconjs.d.ts
3133 lines (2941 loc) · 155 KB
/
baconjs.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for Bacon.js 0.7.0
// Project: https://baconjs.github.io/
// Definitions by: Alexander Matsievsky <https://github.com/alexander-matsievsky>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="../node/node-0.11.d.ts" />
/// <reference path="../es6-promise/es6-promise.d.ts" />
interface JQuery {
/**
* @method
* @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object.
* @param {string} eventName
* @returns {EventStream<ErrorEvent, JQueryEventObject>}
* @example
* $("#my-div").asEventStream("click");
*/
asEventStream(eventName:string):Bacon.EventStream<ErrorEvent, JQueryEventObject>;
/**
* @method
* @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object. You can pass an argument to add a jQuery live `selector`.
* @param {string} eventName
* @param {string} selector
* @returns {EventStream<ErrorEvent, JQueryEventObject>}
* @example
* $("#my-div").asEventStream("click", ".more-specific-selector");
*/
asEventStream(eventName:string, selector:string):Bacon.EventStream<ErrorEvent, JQueryEventObject>;
/**
* @callback JQuery#asEventStream1~f
* @param {JQueryEventObject} event
* @param {*[]} args
* @returns {A}
*/
/**
* @method JQuery#asEventStream1
* @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object. You can pass an argument to add a function `f` that processes the jQuery event and its parameters.
* @param {string} eventName
* @param {JQuery#asEventStream1~f} f
* @returns {EventStream<ErrorEvent, A>}
* @example
* $("#my-div").asEventStream("click", (event, args) => args[0]);
*/
asEventStream<A>(eventName:string, f:(event:JQueryEventObject, args:any[]) => A):Bacon.EventStream<ErrorEvent, A>;
/**
* @callback JQuery#asEventStream2~f
* @param {JQueryEventObject} event
* @param {*[]} args
* @returns {A}
*/
/**
* @method JQuery#asEventStream2
* @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object. You can pass an argument to add a jQuery live `selector` and a function `f` that processes the jQuery event and its parameters.
* @param {string} eventName
* @param {string} selector
* @param {JQuery#asEventStream2~f} f
* @returns {Bacon.EventStream<ErrorEvent, A>}
* @example
* $("#my-div").asEventStream("click", ".more-specific-selector", (event, args) => args[0]);
*/
asEventStream<A>(eventName:string, selector:string, f:(event:JQueryEventObject, args:any[]) => A):Bacon.EventStream<ErrorEvent, A>;
}
/** @module Bacon */
declare module Bacon {
/**
* @function
* @description Creates an [EventStream]{@link Bacon.EventStream} from a `promise` Promise object such as JQuery Ajax. This stream will contain a single value or an error, followed immediately by stream end. You can use the optional `abort` flag (i.e. ´Bacon.fromPromise(p, true)´ to have the `abort` method of the given promise be called when all subscribers have been removed from the created stream.
* @param {Promise<A>|JQueryXHR} promise
* @param {boolean} [abort]
* @returns {EventStream<E, A>}
* @example
* Bacon.fromPromise($.ajax("https://baconjs.github.io/"));
* Bacon.fromPromise(Promise.resolve(1));
* Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true);
* Bacon.fromPromise(Promise.resolve(1), false);
*/
function fromPromise<E, A>(promise:Promise<A>|JQueryXHR, abort?:boolean):EventStream<E, A>;
/**
* @callback Bacon.fromPromise~eventTransformer
* @param {A} value
* @returns {(Initial<B>|Next<B>|End<B>|Error<E>)[]}
*/
/**
* @function Bacon.fromPromise
* @description Creates an [EventStream]{@link Bacon.EventStream} from a `promise` Promise object such as JQuery Ajax. This stream will contain a single value or an error, followed immediately by stream end. You can use the `abort` flag (i.e. ´Bacon.fromPromise(p, true)´ to have the `abort` method of the given promise be called when all subscribers have been removed from the created stream, and also pass a function `eventTransformer` that transforms the promise value into Events. The default is to transform the value into `[new Bacon.Next(value), new Bacon.End()]`.
* @param {Promise<A>|JQueryXHR} promise
* @param {boolean} abort
* @param {Bacon.fromPromise~eventTransformer} eventTransformer
* @returns {EventStream<E, B>}
* @example
* Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true, (n:string) => {
* return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()];
* });
* Bacon.fromPromise(Promise.resolve(1), false, n => {
* return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()];
* });
*/
function fromPromise<E, A, B>(promise:Promise<A>|JQueryXHR, abort:boolean, eventTransformer:(value:A) => (Initial<B>|Next<B>|End<B>|Error<E>)[]):EventStream<E, B>;
/**
* @function
* @description Creates an [EventStream]{@link Bacon.EventStream} from events on a DOM EventTarget or Node.JS EventEmitter object, or an object that supports event listeners using `on`/`off` methods.
* @param {EventTarget|NodeJS.EventEmitter|JQuery} target
* @param {string} eventName
* @returns {EventStream<E, A>}
* @example
* Bacon.fromEvent(document.body, "click").onValue(() => {
* alert("Bacon!");
* });
* Bacon.fromEvent(process.stdin, "readable", () => {
* alert("Bacon!");
* });
* Bacon.fromEvent($("body"), "click").onValue(() => {
* alert("Bacon!");
* });
*/
function fromEvent<E, A>(target:EventTarget|NodeJS.EventEmitter|JQuery, eventName:string):EventStream<E, A>;
/**
* @callback Bacon.fromEvent~eventTransformer
* @param {A} event
* @returns {B}
*/
/**
* @function Bacon.fromEvent
* @description Creates an [EventStream]{@link Bacon.EventStream} from events on a DOM EventTarget or Node.JS EventEmitter object, or an object that supports event listeners using `on`/`off` methods. You can pass a function `eventTransformer` that transforms the emitted events' parameters.
* @param {EventTarget|NodeJS.EventEmitter|JQuery} target
* @param {string} eventName
* @param {Bacon.fromEvent~eventTransformer} eventTransformer
* @returns {EventStream<E, B>}
* @example
* Bacon.fromEvent(document.body, "click", (event:MouseEvent) => event.clientX).onValue(clientX => {
* alert("Bacon!");
* });
*/
function fromEvent<E, A, B>(target:EventTarget|NodeJS.EventEmitter|JQuery, eventName:string, eventTransformer:(event:A) => B):EventStream<E, B>;
/**
* @callback Bacon.fromCallback1~f
* @param {Bacon.fromCallback1~callback} callback
* @returns {void}
*/
/**
* @callback Bacon.fromCallback1~callback
* @param {...*} args
* @returns {void}
*/
/**
* @function Bacon.fromCallback1
* @description Creates an [EventStream]{@link Bacon.EventStream} from a function `f` that accepts a `callback`. The function is supposed to call its callback just once.
* @param {Bacon.fromCallback1~f} f
* @returns {EventStream<E, A>}
* @example
* // This would create a stream that outputs a single value "Bacon!" and ends after that. The use of setTimeout causes the value to be delayed by 1 second.
* Bacon.fromCallback(callback => {
* setTimeout(() => {
* callback("Bacon!");
* }, 1000);
* });
*/
function fromCallback<E, A>(f:(callback:(...args:any[]) => void) => void):EventStream<E, A>;
/**
* @callback Bacon.fromCallback2~f
* @param {...*} args
* @returns {void}
*/
/**
* @function Bacon.fromCallback2
* @description Creates an [EventStream]{@link Bacon.EventStream} from a function `f` that accepts a `callback`. The function is supposed to call its callback just once.
* @param {Bacon.fromCallback2~f} f
* @param {...*} args
* @returns {EventStream<E, A>}
* @example
* // You can also give any number of arguments to `fromCallback`, which will be passed to the function. These arguments can be simple variables, Bacon EventStreams or Properties. For example the following will output "Bacon rules":
* Bacon.fromCallback((a, b, callback) => {
* callback(a + " " + b);
* }, Bacon.constant("bacon"), "rules").log();
*/
function fromCallback<E, A>(f:(...args:any[]) => void, ...args:any[]):EventStream<E, A>;
/**
* @function
* @description Creates an [EventStream]{@link Bacon.EventStream} from a `methodName` method of a given `object`. The function is supposed to call its callback just once.
* @param {Object} object
* @param {string} methodName
* @param {...*} args
* @returns {EventStream<E, A>}
*/
function fromCallback<E, A>(object:Object, methodName:string, ...args:any[]):EventStream<E, A>;
/**
* @callback Bacon.fromNodeCallback~f
* @param {Bacon.fromNodeCallback~callback} callback
* @returns {void}
*/
/**
* @callback Bacon.fromNodeCallback~callback
* @param {E} error
* @param {A} data
* @returns {void}
*/
/**
* @function Bacon.fromNodeCallback
* @description Creates an [EventStream]{@link Bacon.EventStream} from a function `f` that accepts a Node.js `callback`: callback(error, data), where error is `null` if everything is fine. The function is supposed to call its callback just once.
* @param {Bacon.fromNodeCallback~f} f
* @param {...*} args
* @returns {EventStream<E, A>}
* @example
* {
* let fs = require("fs"),
* read = Bacon.fromNodeCallback(fs.readFile, "input.txt");
* read.onError(error => {
* console.log("Reading failed: " + error);
* });
* read.onValue(value => {
* console.log("Read contents: " + value);
* });
* }
*/
function fromNodeCallback<E, A>(f:(callback:(error:E, data:A) => void) => void, ...args:any[]):EventStream<E, A>;
/**
* @function
* @description Creates an [EventStream]{@link Bacon.EventStream} from a `methodName` method of a given `object`.
* @param {Object} object
* @param {string} methodName
* @param {...*} args
* @returns {EventStream<E, A>}
*/
function fromNodeCallback<E, A>(object:Object, methodName:string, ...args:any[]):EventStream<E, A>;
/**
* @callback Bacon.fromPoll~f
* @returns {Next<A>|End<A>}
*/
/**
* @function Bacon.fromPoll
* @description Polls given function `f` with given `interval`. Function should return events: either [Next]{@link Bacon.Next} or [End]{@link Bacon.End}. Polling occurs only when there are subscribers to the stream. Polling ends permanently when `f` returns [End]{@link Bacon.End}.
* @param {number} interval
* @param {Bacon.fromPoll~f} f
* @returns {EventStream<E, A>}
*/
function fromPoll<E, A>(interval:number, f:() => Next<A>|End<A>):EventStream<E, A>;
/**
* @function Bacon.once
* @description Creates an [EventStream]{@link Bacon.EventStream} that delivers the given single `value` for the first subscriber. The stream will end immediately after this value. You can also send an [Error]{@link Bacon.Error} event instead of a `value`.
* @param {A|Error<E>} value
* @returns {EventStream<E, A>}
* @example
* Bacon.once(new Bacon.Error("fail"));
*/
function once<E, A>(value:A|Error<E>):EventStream<E, A>;
/**
* @function
* @description Creates an [EventStream]{@link Bacon.EventStream} that delivers the given series of `values` (given as array) to the first subscriber. The stream ends after these values have been delivered. You can also send [Error]{@link Bacon.Error} events, or any combination of pure values and error events.
* @param {(A|Error<E>)[]} values
* @returns {EventStream<E, A>}
* @example
* Bacon.fromArray([1, new Bacon.Error("")]);
*/
function fromArray<E, A>(values:(A|Error<E>)[]):EventStream<E, A>;
/**
* @function
* @description Repeats the single `value` indefinitely with the given `interval` (in milliseconds).
* @param {number} interval
* @param {A} value
* @returns {EventStream<E, A>}
*/
function interval<E, A>(interval:number, value:A):EventStream<E, A>;
/**
* @function
* @description Creates a [EventStream]{@link Bacon.EventStream} containing given `values` (given as array) with the given `interval` (in milliseconds).
* @param {number} interval
* @param {A[]} values
* @returns {EventStream<E, A>}
*/
function sequentially<E, A>(interval:number, values:A[]):EventStream<E, A>;
/**
* @function
* @description Repeats given `values` indefinitely with then given `interval` (in milliseconds).
* @param {number} interval
* @param {A[]} values
* @returns {EventStream<E, A>}
* @example
* // The following would lead to `1,2,3,1,2,3...` to be repeated indefinitely:
* Bacon.fromArray([1, new Bacon.Error("")]);
*/
function repeatedly<E, A>(interval:number, values:A[]):EventStream<E, A>;
/**
* @callback Bacon.repeat~f
* @param {number} iteration
* @returns {boolean|Observable<E, A>}
*/
/**
* @function Bacon.repeat
* @description Calls generator function `f` which is expected to return an [Observable]{@link Bacon.Observable}. The returned [EventStream]{@link Bacon.EventStream} contains values and errors from the spawned observable. When the spawned Observable ends, the generator `f` is called again to spawn a new Observable. This is repeated until the generator `f` returns a falsy value (such as `undefined` or `false`). The generator `f` is called with one argument — `iteration` number starting from `0`.
* @param {Bacon.repeat~f} f
* @returns {EventStream<E, A>}
* @example
* // The following will produce values `0,1,2`.
* Bacon.repeat(i => {
* if (i < 3) {
* return Bacon.once(i);
* } else {
* return false;
* }
* }).log();
*/
function repeat<E, A>(f:(iteration:number) => boolean|Observable<E, A>):EventStream<E, A>;
/**
* @function Bacon.never
* @description Creates an [EventStream]{@link Bacon.EventStream} that immediately ends.
* @returns {EventStream<E, A>}
*/
function never<E, A>():EventStream<E, A>;
/**
* @function
* @description Creates a single-element [EventStream]{@link Bacon.EventStream} that produces given `value` after a given `delay` (in milliseconds).
* @param {number} delay
* @param {A} value
* @returns {EventStream<E, A>}
*/
function later<E, A>(delay:number, value:A):EventStream<E, A>;
/**
* @function
* @description Creates a constant [Property]{@link Bacon.Property} with value `x`.
* @param {A} x
* @returns {Property<E, A>}
*/
function constant<E, A>(x:A):Property<E, A>;
/**
* @callback Bacon.fromBinder~subscribe
* @param {Bacon.fromBinder~sink} sink
* @returns {Bacon.fromBinder~unsubscribe}
*/
/**
* @callback Bacon.fromBinder~sink
* @param {More|NoMore|(A|Initial<A>|Next<A>|End<A>|Error<E>)|(A|Initial<A>|Next<A>|End<A>|Error<E>)[]} value
* @returns {void}
*/
/**
* @callback Bacon.fromBinder~unsubscribe
* @returns {void}
*/
/**
* @function Bacon.fromBinder
* @description Creates an [EventStream]{@link Bacon.EventStream} with the given [subscribe]{@link Bacon.fromBinder~subscribe} function. The parameter `subscribe` is a function that accepts a [sink]{@link Bacon.fromBinder~sink} which is a function that your `subscribe` function can "push" events to. You can push: a plain value, like `"first value"`; an [Event]{@link Bacon.Event} object including [Error]{@link Bacon.Error} (wraps an error) and [End]{@link Bacon.End} (indicates stream end); an array of event objects at once. The `subscribe` function must return a function. Let's call that function [unsubscribe]{@link Bacon.fromBinder~unsubscribe}. The returned function can be used by the subscriber (directly or indirectly) to unsubscribe from the EventStream. It should release all resources that the `subscribe` function reserved. The `sink` function may return [noMore]{@link Bacon.noMore} (as well as [more]{@link Bacon.more} or any other value). If it returns `noMore`, no further events will be consumed by the subscriber. The `subscribe` function may choose to clean up all resources at this point (e.g., by calling `unsubscribe`). This is usually not necessary, because further calls to `sink` are ignored, but doing so can increase performance in rare cases. The EventStream will wrap your `subscribe` function so that it will only be called when the first stream listener is added, and the `unsubscribe` function is called only after the last listener has been removed. The subscribe-unsubscribe cycle may of course be repeated indefinitely, so prepare for multiple calls to the `subscribe` function.
* @param {Bacon.fromBinder~subscribe} subscribe
* @returns {EventStream<E, A>}
* @example
* let stream = Bacon.fromBinder(sink => {
* sink("first value");
* sink([new Bacon.Next("2nd"), new Bacon.Next("3rd")]);
* sink(new Bacon.Next(() => {
* return "This one will be evaluated lazily"
* }));
* sink(new Bacon.Error("oops, an error"));
* sink(new Bacon.End());
* return () => {
* // unsub functionality here, this one's a no-op
* };
* });
* stream.log();
*/
function fromBinder<E, A>(subscribe:(sink:(value:More|NoMore|(A|Initial<A>|Next<A>|End<A>|Error<E>)|(A|Initial<A>|Next<A>|End<A>|Error<E>)[]) => void) => (() => void)):EventStream<E, A>;
/**
* @interface
* @see Bacon.more
*/
interface More {
}
/**
* @property more
* @constant
* @description The opaque value `sink` function may return. See [Bacon.fromBinder]{@link Bacon.fromBinder}.
*/
var more:More;
/**
* @interface
* @see Bacon.noMore
*/
interface NoMore {
}
/**
* @property noMore
* @constant
* @description The opaque value `sink` function may return. See [Bacon.fromBinder]{@link Bacon.fromBinder}.
*/
var noMore:NoMore;
/**
* @class Observable
* @description A superclass for [EventStream]{@link Bacon.EventStream} and [Property]{@link Bacon.Property}.
* */
interface Observable<E, A> {
/**
* @callback Observable#onValue~f
* @param {A} value
* @returns {void}
*/
/**
* @callback Observable#onValue~unsubscribe
* @returns {void}
*/
/**
* @method Observable#onValue
* @description Subscribes a given handler function `f` to the [Observable]{@link Bacon.Observable}. Function will be called for each new value. This is the simplest way to assign a side-effect to an Observable. The difference to the [EventStream.subscribe]{@link Bacon.EventStream#subscribe} and [Property.subscribe]{@link Bacon.Property#subscribe} methods is that the actual stream `value`s are received, instead of [Event]{@link Bacon.Event} objects. [EventStream.onValue]{@link Bacon.EventStream#onValue} and [Property.onValue]{@link Bacon.Property#onValue} behave similarly, except that the latter also pushes the initial value of the Property, in case there is one.
* @param {Observable#onValue~f} f
* @returns {Observable#onValue~unsubscribe}
*/
onValue(f:(value:A) => void):() => void;
/**
* @callback Observable#onError~f
* @param {E} error
* @returns {void}
*/
/**
* @callback Observable#onError~unsubscribe
* @returns {void}
*/
/**
* @method Observable#onError
* @description Subscribes a given handler function `f` to [Error]{@link Bacon.Error} events. The function `f` will be called for each error in the [Observable]{@link Bacon.Observable}.
* @param {Observable#onError~f} f
* @returns {Observable#onError~unsubscribe}
*/
onError(f:(error:E) => void):() => void;
/**
* @callback Observable#onEnd~f
* @returns {void}
*/
/**
* @callback Observable#onEnd~unsubscribe
* @returns {void}
*/
/**
* @method Observable#onEnd
* @description Subscribes a given handler function `f` to [End]{@link Bacon.End} event. The function `f` will be called when the [Observable]{@link Bacon.Observable} ends. Just like [EventStream.subscribe]{@link Bacon.EventStream#subscribe} and [Property.subscribe]{@link Bacon.Property#subscribe}, this method returns a function for `unsubscribe`ing.
* @param {Observable#onEnd~f} f
* @returns {Observable#onEnd~unsubscribe}
*/
onEnd(f:() => void):() => void;
/**
* @callback Observable#toPromise~promiseCtr
* @param {A} value
* @returns {Promise<A>}
*/
/**
* @method Observable#toPromise
* @description Returns a Promise which will be resolved with the last event coming from an [Observable]{@link Bacon.Observable}. The global ES6 promise implementation will be used unless a promise constructor `promiseCtr` is given. Use a shim if you need to support legacy browsers or platforms.
* @param {Observable#toPromise~promiseCtr} [promiseCtr]
* @returns {Promise<A>}
*/
toPromise(promiseCtr?:(value:A) => Promise<A>):Promise<A>;
/**
* @callback Observable#firstToPromise~promiseCtr
* @param {A} value
* @returns {Promise<A>}
*/
/**
* @method Observable#firstToPromise
* @description Returns a Promise which will be resolved with the first event coming from an [Observable]{@link Bacon.Observable}. Like [Observable.toPromise]{@link Bacon.Observable#toPromise}, the global ES6 promise implementation will be used unless a promise constructor `promiseCtr` is given.
* @param {Observable#firstToPromise~promiseCtr} [promiseCtr]
* @returns {Promise<A>}
*/
firstToPromise(promiseCtr?:(value:A) => Promise<A>):Promise<A>;
/**
* @method
* @description Throttles the [Observable]{@link Bacon.Observable} using a buffer so that at most one value event in `minimumInteval` is issued. Unlike [EventStream.throttle]{@link Bacon.EventStream#throttle} and [Property.throttle]{@link Bacon.Property#throttle}, it doesn't discard the excessive events but buffers them instead, outputting them with a rate of at most one value per `minimumInterval`.
* @param {number} minimumInterval
* @returns {EventStream<E, A>}
*/
bufferingThrottle(minimumInterval:number):EventStream<E, A>;
/**
* @callback Observable#flatMap~f
* @param {A} value
* @returns {B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>}
*/
/**
* @method Observable#flatMap
* @description For each element in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f`, and collect events from each of the spawned streams into the result [EventStream]{@link Bacon.EventStream}. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. The result of [flatMap]{@link Bacon.Observable#flatMap} is always an EventStream. The "Function Construction rules" apply here. `flatMap` can be used conveniently with [Bacon.once]{@link Bacon.once} and [Bacon.never]{@link Bacon.never} for converting and filtering at the same time, including only some of the results.
* @param {Observable#flatMap~f} f
* @returns {EventStream<E, B>}
* @example
* // Converting strings to integers, skipping empty values:
* Bacon.once("").flatMap(text => {
* return text != "" ? parseInt(text) : Bacon.never();
* });
*/
flatMap<B>(f:(value:A) => B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>):EventStream<E, B>;
/**
* @callback Observable#flatMapLatest~f
* @param {A} value
* @returns {B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>}
*/
/**
* @method Observable#flatMapLatest
* @description For each element in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f`, but instead of including events from all spawned streams, only includes them from the latest spawned stream into the result [EventStream]{@link Bacon.EventStream}. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. The result of [flatMapLatest]{@link Bacon.Observable#flatMapLatest} is always an EventStream.
* @param {Observable#flatMapLatest~f} f
* @returns {EventStream<E, B>}
*/
flatMapLatest<B>(f:(value:A) => B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>):EventStream<E, B>;
/**
* @callback Observable#flatMapFirst~f
* @param {A} value
* @returns {B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>}
*/
/**
* @method Observable#flatMapFirst
* @description For each element in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f` only if the previously spawned stream has ended, and collect events from each of the spawned streams into the result [EventStream]{@link Bacon.EventStream}. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. The result of [flatMapFirst]{@link Bacon.Observable#flatMapFirst} is always an EventStream.
* @param {Observable#flatMapFirst~f} f
* @returns {EventStream<E, B>}
*/
flatMapFirst<B>(f:(value:A) => B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>):EventStream<E, B>;
/**
* @callback Observable#flatMapError~f
* @param {E} error
* @returns {B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>}
*/
/**
* @method Observable#flatMapError
* @description For each [Error]{@link Bacon.Error} event in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f`, and collect events from each of the spawned streams into the result [EventStream]{@link Bacon.EventStream}. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. The result of [flatMapError]{@link Bacon.Observable#flatMapError} is always an EventStream.
* @param {Observable#flatMapError~f} f
* @returns {EventStream<E, B>}
*/
flatMapError<B>(f:(error:E) => B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>):EventStream<E, B>;
/**
* @callback Observable#flatMapWithConcurrencyLimit~f
* @param {A} value
* @returns {B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>}
*/
/**
* @method Observable#flatMapWithConcurrencyLimit
* @description For each element in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f`, and collect events from each of the spawned streams into the result [EventStream]{@link Bacon.EventStream}, but limit the number of open spawned streams and buffers incoming events by `limit` amount. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. [flatMapConcat]{@link Bacon.Observable#flatMapConcat} is [flatMapWithConcurrencyLimit]{@link Bacon.Observable#flatMapWithConcurrencyLimit}(1) (only one input active), and [flatMap]{@link Bacon.Observable#flatMap} is [flatMapWithConcurrencyLimit]{@link Bacon.Observable#flatMapWithConcurrencyLimit}(∞) (all inputs are piped to output). The result of `flatMapWithConcurrencyLimit` is always an EventStream.
* @param {number} limit
* @param {Observable#flatMapWithConcurrencyLimit~f} f
* @returns {EventStream<E, B>}
*/
flatMapWithConcurrencyLimit<B>(limit:number, f:(value:A) => B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>):EventStream<E, B>;
/**
* @callback Observable#flatMapConcat~f
* @param {A} value
* @returns {B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>}
*/
/**
* @method Observable#flatMapConcat
* @description For each element in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f`, and collect events from each of the spawned streams into the result [EventStream]{@link Bacon.EventStream}, but limit the number of open spawned streams and buffers incoming events to 1. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. The result of `flatMapConcat` is always an EventStream.
* @param {Observable#flatMapConcat~f} f
* @returns {EventStream<E, B>}
*/
flatMapConcat<B>(f:(value:A) => B|Initial<B>|Next<B>|End<B>|Error<E>|Observable<E, B>):EventStream<E, B>;
/**
* @callback Observable#scan~f
* @param {B} acc
* @param {A} next
* @returns {B}
*/
/**
* @method Observable#scan
* @description Scans [Observable]{@link Bacon.Observable} with given `seed` value and accumulator function `f`, resulting to a [Property]{@link Bacon.Property}. For example, you might use zero as `seed` and a "plus" function as the accumulator to create an "integral" Property. When applied to a Property as in `r = p.scan(seed, f)`, there's a (hopefully insignificant) catch: the starting value for `r` depends on whether `p` has an initial value when `scan` is applied. If there's no initial value, this works identically to `[EventStream]{@link Bacon.EventStream}.scan`: the `seed` will be the initial value of `r`. However, if `r` already has a current/initial value `x`, the seed won't be output as is. Instead, the initial value of `r` will be `f(seed, x)`. This makes sense, because there can only be 1 initial value for a Property at a time.
* @param {B} seed
* @param {Observable#scan~f} f
* @returns {Property<E, B>}
* @example
* Bacon.sequentially(1, [1, 2, 3]).scan(0, (a, b) => a + b);
*/
scan<B>(seed:B, f:(acc:B, next:A) => B):Property<E, B>;
/**
* @callback Observable#fold~f
* @param {B} acc
* @param {A} next
* @returns {B}
*/
/**
* @method Observable#fold
* @description Scans [Observable]{@link Bacon.Observable} with given `seed` value and accumulator function `f`, but only emits the final value, i.e. the value just before the Observable ends. Returns a [Property]{@link Bacon.Property}.
* @param {B} seed
* @param {Observable#fold~f} f
* @returns {Property<E, B>}
*/
fold<B>(seed:B, f:(acc:B, next:A) => B):Property<E, B>;
/**
* @callback Observable#reduce~f
* @param {B} acc
* @param {A} next
* @returns {B}
*/
/**
* @method Observable#reduce
* @description Scans [Observable]{@link Bacon.Observable} with given `seed` value and accumulator function `f`, but only emits the final value, i.e. the value just before the Observable ends. Returns a [Property]{@link Bacon.Property}.
* @param {B} seed
* @param {Observable#reduce~f} f
* @returns {Property<E, B>}
*/
reduce<B>(seed:B, f:(acc:B, next:A) => B):Property<E, B>;
/**
* @callback Observable#diff~f
* @param {A} a
* @param {B} b
* @returns {B}
*/
/**
* @method Observable#diff
* @description Returns a [Property]{@link Bacon.Property} that represents the result of a comparison `f` between the previous and current value of the [Observable]{@link Bacon.Observable}. For the initial value of the Observable, the previous value will be the given `start`.
* @param {A} start
* @param {Observable#diff~f} f
* @returns {Property<E, B>}
* @example
* Bacon.sequentially(1, [1, 2, 3]).diff(0, (a, b) => Math.abs(b - a));
*/
diff<B>(start:A, f:(a:A, b:A) => B):Property<E, B>;
/**
* @callback Observable#zip~f
* @param {A} a
* @param {B} b
* @returns {C}
*/
/**
* @method Observable#zip
* @description Returns an [EventStream]{@link Bacon.EventStream} with elements pair-wise lined up with events from this and the `other` EventStream. A zipped EventStream will publish only when it has a value from each EventStream and will only produce values up to when any single EventStream ends. The given function `f` is used to create the result value from value in the two source EventStream. If no function `f` is given, the values are zipped into an array. Be careful not to have too much "drift" between streams. If one stream produces many more values than some other excessive buffering will occur inside the zipped observable.
* @param {EventStream<E, B>} other
* @param {Observable#zip~f} f
* @returns {EventStream<E, C>}
* @example
* {
* let x = Bacon.fromArray([1, 2]),
* y = Bacon.fromArray([3, 4]);
* x.zip(y, (x, y) => x + y);
* }
*/
zip<B, C>(other:EventStream<E, B>, f:(a:A, b:B) => C):EventStream<E, C>;
/**
* @method
* @description Returns a [Property]{@link Bacon.Property} that represents a "sliding window" into the history of the values of the [Observable]{@link Bacon.Observable}. The resulting Property will have a value that is an array containing the last `n` values of the original Observable, where `n` is at most the value of the `max` argument, and at least the value of the `min` argument. If the `min` argument is omitted, there's no lower limit of values.
* @param {number} max
* @param {number} [min]
* @returns {Property<E, A[]>}
* @example
* // If you have a EventStream `s` with a value sequence `1,2,3,4,5`, the respective values in `s.slidingWindow(2)` would be `[],[1],[1,2],[2,3],[3,4],[4,5]`:
* Bacon.fromArray([1, 2, 3, 4, 5]).slidingWindow(2);
* // The values of `s.slidingWindow(2,2)`would be `[1,2],[2,3],[3,4],[4,5]`:
* Bacon.fromArray([1, 2, 3, 4, 5]).slidingWindow(2, 2);
*/
slidingWindow(max:number, min?:number):Property<E, A[]>;
/**
* @callback Observable#combine~f
* @param {A} a
* @param {B} b
* @returns {C}
*/
/**
* @method Observable#combine
* @description Combines the latest values of the two [EventStream]{@link Bacon.EventStream}s or [Property]{@link Bacon.Property}s using a two-arg function `f`. The result is a Property.
* @param {Property<E, B>} property2
* @param {Observable#combine~f} f
* @returns {Property<E, C>}
*/
combine<B, C>(property2:Property<E, B>, f:(a:A, b:B) => C):Property<E, C>;
/**
* @callback Observable#withStateMachine~f
* @param {B} state
* @param {Initial<A>|Next<A>|End<A>|Error<E>} event
* @returns {[B, (Initial<C>|Next<C>|End<C>|Error<E>)[]]}
*/
/**
* @method Observable#withStateMachine
* @description Lets you run a state machine on an [Observable]{@link Bacon.Observable}. Give it an initial state `initState` object and a state transformation function `f` that processes each incoming [Event]{@link Bacon.Event} and returns and array containing the next `state` and an array of output Event's.
* @param {B} initState
* @param {Observable#withStateMachine~f} f
* @returns {EventStream<E, C>}
* @example
* // Calculate the total sum of all numbers in the stream and output the value on stream end:
* Bacon.fromArray([1, 2, 3]).withStateMachine(0, (sum, event) => {
* if (event.hasValue()) {
* // had to cast to `number` because event:Bacon.Next<number>|Bacon.Error<{}>
* return [sum + <number>event.value(), []];
* } else if (event.isEnd()) {
* return [undefined, [new Bacon.Next(sum), event]];
* } else {
* return [sum, [event]];
* }
* });
*/
withStateMachine<B, C>(initState:B, f:(state:B, event:Initial<A>|Next<A>|End<A>|Error<E>) => [B, (Initial<C>|Next<C>|End<C>|Error<E>)[]]):EventStream<E, C>;
/**
* @method
* @description Decodes input [Observable]{@link Bacon.Observable} using the given `mapping`. Is a bit like a switch-case or the decode function in Oracle SQL. The return value of `decode` is always a [Property]{@link Bacon.Property}.
* @param {Object} mapping
* @returns {Property<E, B>}
* @example
* {
* let property = Bacon.fromArray([1, 2, 3]).toProperty(),
* who = Bacon.fromArray(["A", "B", "C"]).toProperty();
* // The following would map the value 1 into the string "mike" and the value 2 into the value of the `who` property:
* property.decode({1: "mike", 2: who});
* // You can compose static and dynamic data quite freely, as in:
* property.decode({1: {type: "mike"}, 2: {type: "other", whoThen: who}});
* }
*/
decode<B>(mapping:Object):Property<E, B>;
/**
* @method
* @description Creates a [Property]{@link Bacon.Property} that indicates whether Observable is awaiting `otherObservable`, i.e. has produced a value after the latest value from `otherObservable`.
* @param {Observable<E, B>} otherObservable
* @returns {Property<E, boolean>}
* @example
* {
* // This is handy for keeping track whether we are currently awaiting an AJAX response:
* let ajaxRequest = <Bacon.Observable<Error, JQueryXHR>>{},
* ajaxResponse = <Bacon.Observable<Error, JQueryXHR>>{},
* showAjaxIndicator = ajaxRequest.awaiting(ajaxResponse);
* }
*/
awaiting<B>(otherObservable:Observable<E, B>):Property<E, boolean>;
}
/**
* @class EventStream
* @augments Bacon.Observable
* @description A stream of events.
* */
interface EventStream<E, A> extends Observable<E, A> {
/**
* @callback EventStream#map~f
* @param {A} value
* @returns {B}
*/
/**
* @method EventStream#map
* @description Maps [EventStream]{@link Bacon.EventStream} values using given function `f`, returning a new EventStream. The `map` method, among many others, uses lazy evaluation.
* @param {EventStream#map~f} f
* @returns {EventStream<E, B>}
* */
map<B>(f:(value:A) => B):EventStream<E, B>;
/**
* @method
* @description Maps [EventStream]{@link Bacon.EventStream} values using given `constant` value, returning a new EventStream. The `map` method, among many others, uses lazy evaluation.
* @param {B} constant
* @returns {EventStream<E, B>}
* */
map<B>(constant:B):EventStream<E, B>;
/**
* @method
* @description Maps [EventStream]{@link Bacon.EventStream} values using given `propertyExtractor` string like ".keyCode", returning a new EventStream. So, if `propertyExtractor` is a string starting with a dot, the elements will be mapped to the corresponding field/function in the event value. For instance map(".keyCode") will pluck the keyCode field from the input values. If `keyCode` was a function, the result EventStream would contain the values returned by the function. The "Function Construction rules" apply here. The `map` method, among many others, uses lazy evaluation.
* @param {string} propertyExtractor
* @returns {EventStream<E, B>}
* */
map<B>(propertyExtractor:string):EventStream<E, B>;
/**
* @method
* @description Maps [EventStream]{@link Bacon.EventStream} events to the current value of the given [Property]{@link Bacon.Property} `property`. This is equivalent to [Property.sampledBy]{@link Bacon.Property#sampledBy}.
* @param {Property<E, B>} property
* @returns {EventStream<E, B>}
*/
map<B>(property:Property<E, B>):EventStream<E, B>;
/**
* @callback EventStream#mapError~f
* @param {E} error
* @returns {B}
*/
/**
* @method EventStream#mapError
* @description Maps [EventStream]{@link Bacon.EventStream} [Error]{@link Bacon.Error}s using given function `f`. More specifically, feeds the "error" field of the Error event to the function and produces a [Next]{@link Bacon.Next} event based on the return value. The "Function Construction rules" apply here.
* @param {EventStream#mapError~f} f
* @returns {EventStream<E, A|B>}
*/
mapError<B>(f:(error:E) => B):EventStream<E, A|B>;
/**
* @method
* @description Returns an [EventStream]{@link Bacon.EventStream} containing [Error]{@link Bacon.Error} events only. Same as filtering with a function that always returns `false`.
* @returns {EventStream<E, A>}
*/
errors():EventStream<E, A>;
/**
* @method
* @description Skips all [Error]{@link Bacon.Error}s.
* @returns {EventStream<E, A>}
*/
skipErrors():EventStream<E, A>;
/**
* @callback EventStream#mapEnd~f
* @returns {A}
*/
/**
* @method EventStream#mapEnd
* @description Adds an extra [Next]{@link Bacon.Next} event just before [End]{@link Bacon.End} to [EventStream]{@link Bacon.EventStream}. The value is created by calling the given function `f` when the source [EventStream]{@link Bacon.EventStream} ends.
* @param {EventStream#mapEnd~f} f
* @returns {EventStream<E, A>}
*/
mapEnd(f:() => A):EventStream<E, A>;
/**
* @method
* @description Adds an extra [Next]{@link Bacon.Next} event just before [End]{@link Bacon.End} to [EventStream]{@link Bacon.EventStream}. A static `value` is used.
* @param {A} value
* @returns {EventStream<E, A>}
*/
mapEnd(value:A):EventStream<E, A>;
/**
* @callback EventStream#filter~f
* @param {A} value
* @returns {boolean}
*/
/**
* @method EventStream#filter
* @description Filters [EventStream]{@link Bacon.EventStream} `value`s using a given predicate function `f`.
* @param {EventStream#filter~f} f
* @returns {EventStream<E, A>}
*/
filter(f:(value:A) => boolean):EventStream<E, A>;
/**
* @method
* @description Filters [EventStream]{@link Bacon.EventStream} values using a given `constant` value (`true` to include all, `false` to exclude all).
* @param {boolean} bool
* @returns {EventStream<E, A>}
*/
filter(bool:boolean):EventStream<E, A>;
/**
* @method
* @description Filters [EventStream]{@link Bacon.EventStream} values using a given `propertyExtractor` string (like ".isValuable").
* @param {string} propertyExtractor
* @returns {EventStream<E, A>}
*/
filter(propertyExtractor:string):EventStream<E, A>;
/**
* @method
* @description Filters [EventStream]{@link Bacon.EventStream} values based on the value of a [Property]{@link Bacon.Property} `property`. [Event]{@link Bacon.Event} will be included in output IF AND ONLY IF the `property` holds `true` at the time of the event.
* @param {Property<E, boolean>} property
* @returns {EventStream<E, A>}
*/
filter(property:Property<E, boolean>):EventStream<E, A>;
/**
* @callback EventStream#takeWhile~f
* @param {A} value
* @returns {boolean}
*/
/**
* @method EventStream#takeWhile
* @description Takes [EventStream]{@link Bacon.EventStream} values while given predicate function `f` holds `true`, and then ends.
* @param {EventStream#takeWhile} f
* @returns {EventStream<E, A>}
*/
takeWhile(f:(value:A) => boolean):EventStream<E, A>;
/**
* @method
* @description Takes [EventStream]{@link Bacon.EventStream} values while the value of a `property` holds `true`, and then ends.
* @param {Property<E, boolean>} property
* @returns {EventStream<E, A>}
*/
takeWhile(property:Property<E, boolean>):EventStream<E, A>;
/**
* @method
* @description Takes at most n elements from the [EventStream]{@link Bacon.EventStream}. Equal to `Bacon.never()` if `n <= 0`.
* @param {number} n
* @returns {EventStream<E, A>}
*/
take(n:number):EventStream<E, A>;
/**
* @method
* @description Takes elements from [EventStream]{@link Bacon.EventStream} until a [Next]{@link Bacon.Next} event appears in the EventStream `stream`. If `stream` ends without value, it is ignored.
* @param {EventStream<E, B>} stream
* @returns {EventStream<E, A>}
*/
takeUntil<B>(stream:EventStream<E, B>):EventStream<E, A>;
/**
* @method
* @description Takes the first element from the [EventStream]{@link Bacon.EventStream}. Essentially [Observable.take]{@link Bacon.EventStream#take}(1).
* @returns {EventStream<E, A>}
*/
first():EventStream<E, A>;
/**
* @method
* @description Takes the last element from the [EventStream]{@link Bacon.EventStream}. None, if EventStream is empty.
* @returns {EventStream<E, A>}
* @example
* // This creates the stream which doesn't produce any events and never ends:
* Bacon.interval(1e1, 0).last();
*/
last():EventStream<E, A>;
/**
* @method
* @description Skips the first `n` elements from the [EventStream]{@link Bacon.EventStream}.
* @param {number} n
* @returns {EventStream<E, A>}
*/
skip(n:number):EventStream<E, A>;
/**
* @method
* @description Delays the [EventStream]{@link Bacon.EventStream} by given `delay` (in milliseconds).
* @param {number} delay
* @returns {EventStream<E, A>}
*/
delay(delay:number):EventStream<E, A>;
/**
* @method EventStream#throttle
* @description Throttles the [EventStream]{@link Bacon.EventStream} by given `delay` (in milliseconds). Events are emitted with the minimum interval of `delay`. The implementation is based on [EventStream.bufferWithTime]{@link Bacon.EventStream#bufferWithTime}.
* @param {number} delay
* @returns {EventStream<E, A>}
*/
throttle(delay:number):EventStream<E, A>;
/**
* @method EventStream#debounce
* @description Throttles the [EventStream]{@link Bacon.EventStream} by given `delay` (in milliseconds), but so that event is only emitted after the given "quiet period". The difference of [throttle]{@link Bacon.EventStream#throttle} and [debounce]{@link Bacon.EventStream#debounce} is the same as it is in the same methods in jQuery.
* @param {number} delay
* @returns {EventStream<E, A>}
*/
debounce(delay:number):EventStream<E, A>;
/**
* @method
* @description Passes the first event in the [EventStream]{@link Bacon.EventStream} through, but after that, only passes events after a given `delay` (in milliseconds) have passed since previous output.
* @param {number} delay
* @returns {EventStream<E, A>}
*/
debounceImmediate(delay:number):EventStream<E, A>;
/**
* @callback EventStream#doAction~f
* @param {A} value
* @returns {void}
*/
/**
* @method EventStream#doAction
* @description Returns an [EventStream]{@link Bacon.EventStream} where the function `f` is executed for each value, before dispatching to subscribers. This is useful for debugging, but also for stuff like calling the `preventDefault()` method for events.
* @param {EventStream#doAction~f} f
* @returns {EventStream<E, A>}
*/
doAction(f:(value:A) => void):EventStream<E, A>;
/**
* @method
* @description Returns an [EventStream]{@link Bacon.EventStream} where the `propertyExtractor` string is applied to each value, before dispatching to subscribers. This is useful for debugging, but also for stuff like calling the `preventDefault()` method for events.
* @param {string} propertyExtractor
* @returns {EventStream<E, A>}
*/
doAction(propertyExtractor:string):EventStream<E, A>;
/**
* @callback EventStream#doError~f