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
import canStreamKefir from "can-stream-kefir";
import canStream from "can-stream";
const canStreaming = canStream( canStreamKefir );
import compute from "can-compute";
import DefineMap from "can-define/map/map";
import DefineList from "can-define/list/list";
const MyMap = DefineMap.extend( {
tasks: {
Type: DefineList.List,
value: []
}
} );
const map = new MyMap();
const 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
import canStreamKefir from "can-stream-kefir";
import canStream from "can-stream";
const canStreaming = canStream( canStreamKefir );
import compute from "can-compute";
import DefineMap from "can-define/map/map";
import DefineList from "can-define/list/list";
const MyMap = DefineMap.extend( {
tasks: {
Type: DefineList.List,
value: []
}
} );
const map = new MyMap();
const 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.