can.rx
is a CanJS plugin that lets you
create RxJS Observable
s from
CanJS
event handlers, as well as feed Observable
streams back into CanJS
observables. The result is a delicious, canned-bacon-flavored mix of
FRP and
CanJS
-style declarative MVC.
can.rx
implements the
can.eventstream interface and
adds a few methods to RxJS
objects (documented below). For information on the
CanJS
side of the interface, please refer to can.eventstream
's
documentation.
Check out dist/sandbox.html
and dist/sandbox.js
for some rough usage
examples, including a fairly short drag-and-drop demo using can.Component
, and
super-simple, single-line two-way binding between pairs of computes and pairs of
can.Map
s.
can.rx
is
hosted at Github. can.rx
is a
public domain work, dedicated using
CC0 1.0. Feel free to do
whatever you want with it.
$ npm install can.rx
or
$ bower install can.rx
Prebuilt releases are included in dist
.
var compute = can.compute(),
observable = compute.bind();
observable.subscribe(function(x) { console.log("Value changed: ", x); });
compute(1);
observable.toCompute().bind("change", function() {
console.log("compute updated from property change.");
});
compute(2);
For the most part, can.rx
is a straightforward implementation of the
can.eventstream
interface.
can.rx
also extends Rx.Observable.prototype
with a few utility methods
that directly wrap can.eventstream
functions, documented below.
Wraps can.bindComputeFromStream
.
stream.toCompute(compute)
is the same as can.bindComputeFromStream(stream, compute);
Wraps can.bindMapFromStream
.
stream.toMap(compute)
is the same as can.bindMapFromStream(stream, compute);
Wraps can.bindListFromStream
.
stream.toList(compute)
is the same as can.bindListFromStream(stream, compute);