streamInterface
A streamInterface function.
streamInterface([observable], propAndOrEvent[,event])
The stream interface function returned from can-stream that will be used to add streamable props to a provided DefineMap.prototype or DefineList.prototype and has the following property methods:
- .toStream(observable, propAndOrEvent[,event])
- .toStreamFromProperty(property)
- .toStreamFromEvent(property)
- .toCompute(makeStream(setStream), context):compute
import DefineMap from 'can-define/map/map';
import canDefineStream from 'can-define-stream';
import streamInterface from 'can-stream-kefir';
var Person = DefineMap.extend({
first: "string",
last: "string",
fullName: {
get: function() {
return this.first + " " + this.last;
}
}
});
var john = new Person({ first: 'John' });
john.toStream('.first'); //-> Error (toStream doesn't exist)
var defineStreamAdder = canDefineStream(streamInterface);
defineStreamAdder(Person);
var justin = new Person({ first: 'Justin' });
justin.toStream('.first'); //-> Stream
Use
See streamInterface.
See can-stream-kefir for an example implementation.