stream
typedef
Define a property value from a stream of values.
stream( setterStream )
The stream behavior is an available property definition on the
PropDefinition of all can-define types.
It is useful for deriving values that get can not, for example deriving values based around the change in another value intead of the values themselves.
var Person = DefineMap.extend({
name: "string",
lastValidName: {
stream: function(){
return this.stream(".name").filter(function(name){
return name.indexOf(" ") >= 0;
})
}
}
});
var me = new Person({name: "James"});
me.on("lastValidName", function(lastValid) {
console.log(lastValid)
});
me.name = "JamesAtherton";
me.name = "James Atherton";
//-> console.logs "James Atherton";
me.name = "JustinMeyer";
me.name = "Justin Meyer";
//-> console.logs "Justin Meyer";
The property must be bound before a value can be read.
Parameters
- setterStream
{Stream}:The stream of values set on this property like
obj.prop = value.
Returns
{Stream}:
A stream whose last value will be used as the property value.