1 | # Deprecated API Methods documentation
|
2 |
|
3 | All documentation on deprecated methods are moved
|
4 | from [main docs](http://kefirjs.github.io/kefir/) to this file.
|
5 |
|
6 | See also [2.x's version of this document](https://github.com/kefirjs/kefir/blob/v2/deprecated-api-docs.md) containing docs on methods that were removed in 3.0.
|
7 |
|
8 |
|
9 | ### `obs.awaiting(otherObs)` [#145](https://github.com/kefirjs/kefir/issues/145)
|
10 |
|
11 | Returns a property that represents the awaiting status of two observables,
|
12 | i.e. answers the question «Has **obs** observable emitted a value since
|
13 | the last value from **otherObs** observable has been emitted?».
|
14 |
|
15 |
|
16 | ```js
|
17 | var foo = Kefir.sequentially(100, [1, 2, 3]);
|
18 | var bar = Kefir.sequentially(100, [1, 2, 3]).delay(40);
|
19 | var result = foo.awaiting(bar);
|
20 | result.log();
|
21 | ```
|
22 |
|
23 | ```
|
24 | > [sequentially.awaiting] <value:current> false
|
25 | > [sequentially.awaiting] <value> true
|
26 | > [sequentially.awaiting] <value> false
|
27 | > [sequentially.awaiting] <value> true
|
28 | > [sequentially.awaiting] <value> false
|
29 | > [sequentially.awaiting] <value> true
|
30 | > [sequentially.awaiting] <value> false
|
31 | > [sequentially.awaiting] <end>
|
32 | ```
|
33 |
|
34 | ```
|
35 | foo: ----1----2----3X
|
36 | bar: ------1----2----3X
|
37 |
|
38 | result: f---t-f--t-f--t-fX
|
39 | ```
|
40 |
|
41 |
|
42 | ### `obs.valuesToErrors([handler])` [#149](https://github.com/kefirjs/kefir/issues/149)
|
43 |
|
44 | Converts values to errors. By default it converts all values to errors,
|
45 | but you can specify a custom **handler** function to change that. The **handler**
|
46 | function is called with one argument — a value, and must return an object
|
47 | with two properties `{convert: Boolean, error: AnyType}`, if **convert** is set
|
48 | to true, the specified **error** will be emitted, otherwise the original value
|
49 | will be emitted, and the **error** property will be ignored.
|
50 |
|
51 | ```js
|
52 | var source = Kefir.sequentially(100, [0, -1, 2, -3]);
|
53 | var result = source.valuesToErrors(x => {
|
54 | return {
|
55 | convert: x < 0,
|
56 | error: x * 2
|
57 | };
|
58 | });
|
59 | result.log();
|
60 | ```
|
61 |
|
62 | ```
|
63 | > [sequentially.valuesToErrors] <value> 0
|
64 | > [sequentially.valuesToErrors] <error> -2
|
65 | > [sequentially.valuesToErrors] <value> 2
|
66 | > [sequentially.valuesToErrors] <error> -6
|
67 | > [sequentially.valuesToErrors] <end>
|
68 | ```
|
69 |
|
70 | ```
|
71 | source: ---•---•---•---•X
|
72 | 0 -1 2 -3
|
73 | result: ---•---e---•---eX
|
74 | 0 -2 2 -6
|
75 | ```
|
76 |
|
77 |
|
78 | ### `obs.errorsToValues([handler])` [#149](https://github.com/kefirjs/kefir/issues/149)
|
79 |
|
80 | Same as valuesToErrors but vice versa.
|
81 |
|
82 | ```js
|
83 | var source = Kefir.sequentially(100, [0, -1, 2, -3]).valuesToErrors();
|
84 | var result = source.errorsToValues(x => {
|
85 | return {
|
86 | convert: x >= 0,
|
87 | value: x * 2
|
88 | };
|
89 | });
|
90 | result.log();
|
91 | ```
|
92 |
|
93 | ```
|
94 | > [sequentially.valuesToErrors.errorsToValues] <value> 0
|
95 | > [sequentially.valuesToErrors.errorsToValues] <error> -1
|
96 | > [sequentially.valuesToErrors.errorsToValues] <value> 4
|
97 | > [sequentially.valuesToErrors.errorsToValues] <error> -3
|
98 | > [sequentially.valuesToErrors.errorsToValues] <end>
|
99 | ```
|
100 |
|
101 | ```
|
102 | source: ---e---e---e---eX
|
103 | 0 -1 2 -3
|
104 | result: ---•---e---•---eX
|
105 | 0 -1 4 -3
|
106 | ```
|
107 |
|
108 |
|
109 | ### `obs.endOnError()` [#150](https://github.com/kefirjs/kefir/issues/150)
|
110 |
|
111 | Makes an observable to end on first error.
|
112 |
|
113 | ```js
|
114 | var source = Kefir.sequentially(100, [0, -1, 2, -3])
|
115 | .valuesToErrors(x => {
|
116 | return {convert: x < 0, error: x};
|
117 | });
|
118 | var result = source.endOnError()
|
119 | result.log();
|
120 | ```
|
121 |
|
122 | ```
|
123 | > [sequentially.valuesToErrors.endOnError] <value> 0
|
124 | > [sequentially.valuesToErrors.endOnError] <error> -1
|
125 | > [sequentially.valuesToErrors.endOnError] <end>
|
126 | ```
|
127 |
|
128 | ```
|
129 | source: ---•---e---•---eX
|
130 | 0 -1 2 -3
|
131 | result: ---•---eX
|
132 | 0 -1
|
133 | ```
|