toStreamFromEvent
Creates a stream on a {Observable} object that gets updated whenever the event occurs on the observable object.
canStream.toStreamFromEvent( obs, eventName )
Creates a stream based on event on observable
var canStreamKefir = require('can-stream-kefir');
var canStream = require('can-stream');
var canStreaming = canStream(canStreamKefir);
var compute = require('can-compute');
var DefineMap = require('can-define/map/map');
var DefineList = require('can-define/list/list');
var MyMap = DefineMap.extend({
tasks: {
Type: DefineList.List,
value: []
}
});
var map = new MyMap();
var stream = canStreaming.toStreamFromEvent(map, 'tasks');
stream.onValue(function(ev){
console.log('map.tasks has been updated');
});
map.fooList.push('New task');
Parameters
- An
{Observable}
:observable object
- property
{String}
:name
Returns
{Stream}
:
A stream.
canStream.toStreamFromEvent( obs, propName, eventName )
Creates a stream based on event trigger on observable property
var canStreamKefir = require('can-stream-kefir');
var canStream = require('can-stream');
var canStreaming = canStream(canStreamKefir);
var compute = require('can-compute');
var DefineMap = require('can-define/map/map');
var DefineList = require('can-define/list/list');
var MyMap = DefineMap.extend({
tasks: {
Type: DefineList.List,
value: []
}
});
var map = new MyMap();
var stream = canStreaming.toStreamFromEvent(map, 'tasks', 'length');
stream.onValue(function(ev){
console.log('map.tasks has been updated');
});
map.fooList.push('New task');
Parameters
- An
{Observable}
:observable object
- observable
{String}
:property name
- observable
{String}
:event name
Returns
{Stream}
:
A stream.