1 | ## Comparison of public APIs of `Bacon v0.7.52` and `Kefir v2.0.0`
|
2 |
|
3 |
|
4 |
|
5 | ### Create Stream
|
6 |
|
7 | | Bacon | Kefir | Comments |
|
8 | | ----- | ----- | -------- |
|
9 | | `$.fn.asEventStream(eventName, [selector], [eventTransformer])` | Use `Kefir.fromEvents($(...), eventName, [eventTransformer])` | |
|
10 | | `Bacon.fromPromise(promise, [abort])` | `Kefir.fromPromise(promise)` | No `abort` option in Kefir, and the result is a Property unlike Stream in Bacon |
|
11 | | `Bacon.fromEvent(target, eventName, [eventTransformer])` | `Kefir.fromEvents(target, eventName, [eventTransformer])` | |
|
12 | | `Bacon.fromCallback(f, [args...])` | `Kefir.fromCallback(fn)` | No `args` argument in Kefir |
|
13 | | `Bacon.fromCallback(object, methodName, [args...])` | No alt. | |
|
14 | | `Bacon.fromNodeCallback(f, [args...])` | `Kefir.fromNodeCallback(fn)` | No `args` argument in Kefir |
|
15 | | `Bacon.fromNodeCallback(object, methodName, [args...])` | No alt. | |
|
16 | | `Bacon.fromPoll(interval, fn)` | `Kefir.fromPoll(interval, fn)` | In Kefir there is no feature "Polling ends permanently when f returns Bacon.End" |
|
17 | | `Bacon.once(value)` | No alt., considered harmful, use `Kefir.constant(value)` instead | |
|
18 | | `Bacon.fromArray(values)` | No alt., considered harmful, try to use `Kefir.sequentially(0, values)` instead | |
|
19 | | `Bacon.interval(interval, value)` | `Kefir.interval(interval, value)` | |
|
20 | | `Bacon.sequentially(interval, values)` | `Kefir.sequentially(interval, values)` | |
|
21 | | `Bacon.repeatedly(interval, values)` | Use `Kefir.repeat(() => Kefir.sequentially(interval, values))` | |
|
22 | | `Bacon.repeat(fn)` | `Kefir.repeat(fn)` | |
|
23 | | `Bacon.never()` | `Kefir.never()` | |
|
24 | | `Bacon.later(delay, value)` | `Kefir.later(delay, value)` | |
|
25 | | `new Bacon.EventStream(subscribe)` | Use `Kefir.stream()` | |
|
26 | | Use bus | `Kefir.emitter()` | |
|
27 | | `Bacon.fromBinder(subscribe)` | `Kefir.stream(subscribe)` | In Kefir [emitter](https://kefirjs.github.io/kefir/#emitter-object) is used unlike `sink` function in Bacon. In Kefir there is no feature "The sink function may return Bacon.noMore ..." |
|
28 | | No alt. | `Kefir.withInterval(interval, handler)` | |
|
29 |
|
30 |
|
31 |
|
32 | ### Create Property
|
33 |
|
34 | | Bacon | Kefir | Comments |
|
35 | | ----- | ----- | -------- |
|
36 | | `Bacon.constant(value)` | `Kefir.constant(value)` | |
|
37 | | No alt. | `Kefir.constantError(error)` | Bacon properties can't have current error, only values |
|
38 | | `Bacon.fromPromise(promise, [abort])` | `Kefir.fromPromise(promise)` | This method was alredy mentioned in "Create Stream" section, duplicated here as Kefir's version returns a Property |
|
39 |
|
40 |
|
41 | ### Convert observables
|
42 |
|
43 | | Bacon | Kefir | Comments |
|
44 | | ----- | ----- | -------- |
|
45 | | `property.changes()` | `property.changes()` | |
|
46 | | `property.toEventStream()` | No alt. | |
|
47 | | `stream.toProperty([current])` | `stream.toProperty([getCurrent])` | Kefir accepts a callback instead of just a value |
|
48 |
|
49 |
|
50 |
|
51 | ### Main observable methods
|
52 |
|
53 | | Bacon | Kefir | Comments |
|
54 | | ----- | ----- | -------- |
|
55 | | `obs.onValue(fn)` | `obs.onValue(fn)` | Kefir returns `this` for chaining, unlike Bacon that returns `unsubscribe` function. Also Kefir doesn't support feature of unsubscribing by return `noMore` special value. |
|
56 | | `obs.onError(fn)` | `obs.onError(fn)` | Same as for `obs.onValue` |
|
57 | | `obs.onEnd(fn)` | `obs.onEnd(fn)` | Same as for `obs.onValue` |
|
58 | | `obs.subscribe(fn)` | `obs.onAny(fn)` | Same as for `obs.onValue`, plus there is differencies in event object API |
|
59 | | Use `unsub` function, or `Bacon.noMore` | `obs.offValue(fn)` | |
|
60 | | Use `unsub` function, or `Bacon.noMore` | `obs.offError(fn)` | |
|
61 | | Use `unsub` function, or `Bacon.noMore` | `obs.offEnd(fn)` | |
|
62 | | Use `unsub` function, or `Bacon.noMore` | `obs.offAny(fn)` | |
|
63 | | `obs.log([name])` | `obs.log([name])` | The log format is different. Kefir returns `this` unlike Bacon, that returns `unusb` function |
|
64 | | Use `unsub` function | `obs.offLog([name])` | |
|
65 | | `obs.name(newName)` | `obs.setName(newName)` | |
|
66 | | `observable.withDescription(param...)` | No alt. | |
|
67 | | `property.assign(obj, method, [param...])` | No alt. | This is basically alias for `.onValue` and all magic done by [Function Construction rules](https://github.com/baconjs/bacon.js#function-construction-rules) which Kefir doesn't support |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | ### Modify an observable
|
73 |
|
74 | | Bacon | Kefir | Comments |
|
75 | | ----- | ----- | -------- |
|
76 | | `obs.map(fn)` | `obs.map(fn)` | |
|
77 | | `obs.mapError(fn)` | `obs.errorsToValues(fn)` | In Kefir you supposed to return an object with shape `{convert: Bool, value: Any}`, in Bacon you return `Event`. |
|
78 | | No alt. | `obs.mapErrors(fn)` | Just like `.map` but for errors. Doesn't convert errors to values or something. |
|
79 | | `obs.errors()` | `obs.skipValues()` | |
|
80 | | `obs.skipErrors()` | `obs.skipErrors()` | |
|
81 | | No alt. | `obs.skipEnd()` | |
|
82 | | `obs.mapEnd(fn)` | `obs.beforeEnd(fn)` | |
|
83 | | `obs.filter(predicate)` | `obs.filter(predicate)` | |
|
84 | | `obs.takeWhile(predicate)` | `obs.takeWhile(predicate)` | |
|
85 | | `obs.take(n)` | `obs.take(n)` | |
|
86 | | `obs.delay(delay)` | `obs.delay(delay)` | |
|
87 | | `obs.throttle(delay)` | `obs.throttle(delay, [options])` | Kefir accepts underscore-like options object |
|
88 | | `obs.debounce(delay)` | `obs.debounce(delay, [options])` | Kefir accepts underscore-like options object |
|
89 | | `obs.debounceImmediate(delay)` | `obs.debounce(delay, {immediate: true})` | |
|
90 | | `obs.bufferingThrottle(minimumInterval)` | No alt. | |
|
91 | | `obs.doAction(fn)` | Use `obs.map((x) => {fn(x); return x;})` | |
|
92 | | `obs.not()` | Use `obs.map((x) => !x)` | |
|
93 | | `obs.scan(seed, fn)` | `obs.scan(fn, [seed])` | In Kefir, `seed` goes second and is optional. |
|
94 | | `obs.reduce(seed, fn)` | `obs.reduce(fn, [seed])` | In Kefir, `seed` goes second and is optional. In Bacon there is also `.fold` alias for `.reduce` |
|
95 | | `obs.diff(start, fn)` | `obs.diff([fn], [seed])` | In Kefir both args are optional, and with different order. |
|
96 | | `obs.slidingWindow(max, [min])` | `obs.slidingWindow(max, [min])` | |
|
97 | | `obs.map(value)` | Use `obs.map(() => value)` | |
|
98 | | `obs.map('.foo')` | `obs.map((x) => x.foo)` | |
|
99 | | `obs.map('.foo')` where `foo` is a method | `obs.map((x) => x.foo())` | |
|
100 | | `obs.skip(n)` | `obs.skip(n)` | |
|
101 | | `obs.skipWhile(predicate)` | `obs.skipWhile([predicate])` | In Kefir `predicate` is optional |
|
102 | | `obs.skipDuplicates([comparator])` | `obs.skipDuplicates([comparator])` | |
|
103 | | No alt. | `obs.flatten([transformer])` | |
|
104 | | No alt. | `obs.transduce(transducer)` | |
|
105 | | No alt. | `obs.valuesToErrors([handler])` | |
|
106 | | No alt. | `obs.filterErrors([predicate])` | |
|
107 | | `obs.endOnError([predicate])` | `obs.endOnError()` | Bacon allows to provide predicate function to end only on certain errors |
|
108 | | `obs.withStateMachine(initState, f)` | No alt. | |
|
109 | | `obs.decode(mapping)` | No alt. | |
|
110 | | `obs.withHandler(handler)` | `obs.withHandler(handler)` | Same functionality but API (inside `handler`) is pretty different |
|
111 | | `obs.startWith(value)` | No alt. | |
|
112 | | No alt. | `obs.bufferWhile([predicate], [options])` | |
|
113 | | `stream.bufferWithTime(delay)` | No alt. | |
|
114 | | `stream.bufferWithTime(f)` | No alt. | |
|
115 | | `stream.bufferWithCount(count)` | No alt. | |
|
116 | | `stream.bufferWithTimeOrCount(delay, count)` | No alt. | |
|
117 | | `property.sample(interval)` | No alt. | |
|
118 | | `obs.toPromise([PromiseConstructor])` | No alt. | |
|
119 | | `obs.first()` | No alt. | |
|
120 | | `obs.last()` | No alt. | |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 | ### Combine observables
|
126 |
|
127 | | Bacon | Kefir | Comments |
|
128 | | ----- | ----- | -------- |
|
129 | | `Bacon.combineAsArray(obss)`, `Bacon.combineWith(f, obs1, obs2...)` | `Kefir.combine(obss, [fn])` | |
|
130 | | `Bacon.combineTemplate(template)` | No alt. | |
|
131 | | No alt. | `Kefir.combine(obss, passiveObs, [fn])` | Bacon only has similar two arity `.sampledBy` method (see below) |
|
132 | | `Bacon.zipAsArray(streams)`, `Bacon.zipWith(streams, f)` | `Kefir.zip(sources, [combinator])` | In Kefir you can also pass ordinary arrays among with observables in `sources` |
|
133 | | `Bacon.mergeAll(streams)` | `Kefir.merge(obss)` | Bacon supports only Streams |
|
134 | | No alt. | `Kefir.concat(obss)` | Bacon only supports two arity `.concat` (see below) |
|
135 | | `new Bacon.Bus()` | No alt. | |
|
136 | | Use Bus | `Kefir.pool()` | |
|
137 | | `obs.flatMap(fn)` | `obs.flatMap([fn])` | In Kefir `fn` is optional |
|
138 | | `obs.flatMapLatest(fn)` | `obs.flatMapLatest([fn])` | In Kefir `fn` is optional |
|
139 | | `obs.flatMapFirst(fn)` | `obs.flatMapFirst([fn])` | In Kefir `fn` is optional |
|
140 | | `obs.flatMapError(fn)` | No alt. | |
|
141 | | `obs.flatMapWithConcurrencyLimit(limit, fn)` | `obs.flatMapConcurLimit([fn], limit)` | In Kefir `fn` is optional, diff args order |
|
142 | | `obs.flatMapConcat(fn)` | `obs.flatMapConcat([fn])` | In Kefir `fn` is optional |
|
143 | | `Bacon.onValues(a, b, [c...], f)` | No alt. | |
|
144 | | `Bacon.when()` | No alt. | |
|
145 | | `Bacon.update()` | No alt. | |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | ### Combine two observables
|
151 |
|
152 | | Bacon | Kefir | Comments |
|
153 | | ----- | ----- | -------- |
|
154 | | `stream.map(property)` | Use `.sampledBy()` | |
|
155 | | `obs.filter(property)` | `obs.filterBy(obs)` | |
|
156 | | `obs.takeWhile(property)` | `obs.takeWhileBy(obs)` | Bacon supports only Property in second position. See also `obs.takeWhile(predicate)` above. |
|
157 | | `obs.combine(obs2, fn)` | `obs.combine(obs2, [fn])` | In Kefir `fn` is optional |
|
158 | | `stream.skipWhile(property)` | `obs.skipWhileBy(otherObs)` | Bacon supports only (Stream, Property) pair as operands. See also `obs.skipWhile(predicate)` above. |
|
159 | | `stream.skipUntil(otherObs)` | `obs.skipUntilBy(otherObs)` | Bacon supports only Streams in first position. |
|
160 | | `stream.takeUntil(otherObs) ` | `obs.takeUntilBy(otherObs)` | Bacon supports only Streams in first position. |
|
161 | | No alt. | `obs.bufferBy(otherObs, [options])` | |
|
162 | | `obs.awaiting(otherObs)` | `obs.awaiting(otherObs)` | |
|
163 | | `obs.zip(other, fn)` | `obs.zip(other, [fn])` | In Kefir `fn` is optional, and you can also pass array as `other` arg |
|
164 | | `property.sampledBy(obs, [fn])` | `obs.sampledBy(obs, [fn])` | |
|
165 | | `property.and(other)` | No alt. | |
|
166 | | `property.or(other)` | No alt. | |
|
167 | | `stream.concat(otherStream)` | `obs.concat(otherObs)` | Bacon supports only Streams as operands |
|
168 | | `stream.merge(otherStream)` | `obs.merge(otherObs)` | Bacon supports only Streams as operands |
|
169 | | `stream.holdWhen(property)` | `obs.bufferWhileBy(otherObs, [options])` | Bacon supports only (Stream, Property) pair as operands |
|
170 |
|
171 |
|
172 |
|
173 | ### Other features
|
174 |
|
175 | | Bacon | Kefir | Comments |
|
176 | | ----- | ----- | -------- |
|
177 | | [Function Construction rules](https://github.com/baconjs/bacon.js#function-construction-rules) | Not supported | |
|
178 | | [Atomic updates](https://github.com/baconjs/bacon.js#atomic-updates) | Not supported | |
|
179 | | Meaningful `.toString` | Partial support | Kefir doesn't show arguments only chain of method names |
|
180 | | [Lazy evaluation](https://github.com/baconjs/bacon.js#lazy-evaluation) | Not supported | |
|