Skip to content

Commit 393f271

Browse files
committed
Document ES observable interoperability
1 parent b27a709 commit 393f271

File tree

2 files changed

+42
-16
lines changed

2 files changed

+42
-16
lines changed

README.md

+20-8
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ read.onError(function(error) { console.log("Reading failed: " + error); });
269269
read.onValue(function(value) { console.log("Read contents: " + value); });
270270
```
271271

272+
<a name="bacon-fromesobservable"></a>
273+
[`Bacon.fromESObservable(observable)`](#bacon-fromesobservable "Bacon.fromESObservable(observable : ESObservable[A]) : EventStream[A]") creates an EventStream from an
274+
[ES Observable](https://github.com/tc39/proposal-observable). Input can be any
275+
ES Observable implementation including RxJS and Kefir.
276+
272277
<a name="bacon-fromnodecallback-object"></a>
273278
[`Bacon.fromNodeCallback(object, methodName [, args...])`](#bacon-fromnodecallback-object "Bacon.fromNodeCallback(object, methodName [, args...])") a variant of fromNodeCallback which calls the named method of a given object.
274279

@@ -475,6 +480,13 @@ Use a shim if you need to support legacy browsers or platforms.
475480
Like [`toPromise`](#observable-topromise), the global ES6 promise implementation will be used unless a promise
476481
constructor is given.
477482

483+
<a name="observable-toesobservable"></a>
484+
[`observable.toESObservable()`](#observable-toesobservable "observable.toESObservable() : ESObservable[A]") Aliased as `observable[Symbol.observable]()`. Returns an
485+
[ES Observable](https://github.com/zenparsing/es-observable) containing the
486+
events from Bacon observable. This allows Bacon observables to be used with
487+
`Observable.from` and provides interoperability with other ES observable
488+
implementations such as RxJS and Kefir.
489+
478490
<a name="observable-map"></a>
479491
[`observable.map(f)`](#observable-map "observable.map(@ : Observable[A], f : A -> B) : Observable[B]") maps values using given function, returning a new
480492
stream/property. Instead of a function, you can also provide a constant
@@ -1708,18 +1720,18 @@ Bacon.js provides ways to get some descriptive metadata about all Observables.
17081720

17091721

17101722
<a name="observable-deps"></a>
1711-
[`observable.deps`](#observable-deps "observable.deps") Returns the an array of dependencies that the Observable has. For instance, for `a.map(function() {}).deps()`, would return `[a]`.
1712-
This method returns the "visible" dependencies only, skipping internal details. This method is thus suitable for visualization tools.
1713-
Internally, many combinator functions depend on other combinators to create intermediate Observables that the result will actually depend on.
1723+
[`observable.deps`](#observable-deps "observable.deps") Returns the an array of dependencies that the Observable has. For instance, for `a.map(function() {}).deps()`, would return `[a]`.
1724+
This method returns the "visible" dependencies only, skipping internal details. This method is thus suitable for visualization tools.
1725+
Internally, many combinator functions depend on other combinators to create intermediate Observables that the result will actually depend on.
17141726
The [`deps`](#observable-deps) method will skip these internal dependencies.
17151727

17161728
<a name="observable-internaldeps"></a>
1717-
[`observable.internalDeps`](#observable-internaldeps "observable.internalDeps") Returns the true dependencies of the observable, including the intermediate "hidden" Observables.
1729+
[`observable.internalDeps`](#observable-internaldeps "observable.internalDeps") Returns the true dependencies of the observable, including the intermediate "hidden" Observables.
17181730
This method is for Bacon.js internal purposes but could be useful for debugging/analysis tools as well.
17191731

17201732
<a name="observable-desc"></a>
1721-
[`observable.desc()`](#observable-desc "observable.desc()") Contains a structured version of what [`toString`](#observable-tostring) returns.
1722-
The structured description is an object that contains the fields `context`, `method` and `args`.
1733+
[`observable.desc()`](#observable-desc "observable.desc()") Contains a structured version of what [`toString`](#observable-tostring) returns.
1734+
The structured description is an object that contains the fields `context`, `method` and `args`.
17231735
For example, for `Bacon.fromArray([1,2,3]).desc` you'd get
17241736

17251737
{ context: Bacon, method: "fromArray", args: [[1,2,3]] }
@@ -1728,8 +1740,8 @@ Notice that this is a field, not a function.
17281740

17291741
<a name="bacon-spy"></a>
17301742
[`Bacon.spy(f)`](#bacon-spy "Bacon.spy(f)")
1731-
Adds your function as a "spy" that will get notified on all new Observables.
1732-
This will allow a visualization/analytis tool to spy on all Bacon activity.
1743+
Adds your function as a "spy" that will get notified on all new Observables.
1744+
This will allow a visualization/analytis tool to spy on all Bacon activity.
17331745

17341746
Cleaning up
17351747
-----------

readme-src.coffee

+22-8
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ read.onValue(function(value) { console.log("Read contents: " + value); });
233233
```
234234
"""
235235

236+
doc.fn "Bacon.fromESObservable(observable : ESObservable[A]) : EventStream[A]", """
237+
creates an EventStream from an
238+
[ES Observable](https://github.com/tc39/proposal-observable). Input can be any
239+
ES Observable implementation including RxJS and Kefir.
240+
"""
241+
236242
doc.fnOverload "Bacon.fromNodeCallback(object, methodName [, args...])", "object", """
237243
a variant of fromNodeCallback which calls the named method of a given object.
238244
"""
@@ -458,6 +464,14 @@ Like `toPromise`, the global ES6 promise implementation will be used unless a pr
458464
constructor is given.
459465
"""
460466

467+
doc.fn "observable.toESObservable() : ESObservable[A]", """
468+
Aliased as `observable[Symbol.observable]()`. Returns an
469+
[ES Observable](https://github.com/zenparsing/es-observable) containing the
470+
events from Bacon observable. This allows Bacon observables to be used with
471+
`Observable.from` and provides interoperability with other ES observable
472+
implementations such as RxJS and Kefir.
473+
"""
474+
461475
doc.fn "observable.map(@ : Observable[A], f : A -> B) : Observable[B]", """
462476
maps values using given function, returning a new
463477
stream/property. Instead of a function, you can also provide a constant
@@ -1782,20 +1796,20 @@ doc.fn "observable.toString", """Returns a textual description of the Observable
17821796
17831797
"""
17841798

1785-
doc.fn "observable.deps", """Returns the an array of dependencies that the Observable has. For instance, for `a.map(function() {}).deps()`, would return `[a]`.
1786-
This method returns the "visible" dependencies only, skipping internal details. This method is thus suitable for visualization tools.
1787-
Internally, many combinator functions depend on other combinators to create intermediate Observables that the result will actually depend on.
1799+
doc.fn "observable.deps", """Returns the an array of dependencies that the Observable has. For instance, for `a.map(function() {}).deps()`, would return `[a]`.
1800+
This method returns the "visible" dependencies only, skipping internal details. This method is thus suitable for visualization tools.
1801+
Internally, many combinator functions depend on other combinators to create intermediate Observables that the result will actually depend on.
17881802
The `deps` method will skip these internal dependencies.
17891803
"""
17901804

17911805
doc.fn "observable.internalDeps", """
1792-
Returns the true dependencies of the observable, including the intermediate "hidden" Observables.
1806+
Returns the true dependencies of the observable, including the intermediate "hidden" Observables.
17931807
This method is for Bacon.js internal purposes but could be useful for debugging/analysis tools as well.
17941808
"""
17951809

17961810
doc.fn "observable.desc()", """
1797-
Contains a structured version of what `toString` returns.
1798-
The structured description is an object that contains the fields `context`, `method` and `args`.
1811+
Contains a structured version of what `toString` returns.
1812+
The structured description is an object that contains the fields `context`, `method` and `args`.
17991813
For example, for `Bacon.fromArray([1,2,3]).desc` you'd get
18001814
18011815
{ context: Bacon, method: "fromArray", args: [[1,2,3]] }
@@ -1805,8 +1819,8 @@ Notice that this is a field, not a function.
18051819

18061820
doc.fn "Bacon.spy(f)", """
18071821
1808-
Adds your function as a "spy" that will get notified on all new Observables.
1809-
This will allow a visualization/analytis tool to spy on all Bacon activity.
1822+
Adds your function as a "spy" that will get notified on all new Observables.
1823+
This will allow a visualization/analytis tool to spy on all Bacon activity.
18101824
"""
18111825

18121826
doc.subsection "Cleaning up"

0 commit comments

Comments
 (0)