can-stream-kefir
Convert observable values into streams. Kefir is used to provide the stream functionality.
Object
The can-stream-kefir
module exports methods useful for converting observable values like can-computes
or can-define/map/map properties into streams.
var canStream = require("can-stream-kefir");
var DefineMap = require("can-define/map/map");
var me = new DefineMap({name: "Justin"});
var nameStream = canStream.toStream(me,".name");
nameStream.onValue(function(name){
// name -> "Obaid";
});
me.name = "Obaid";
Usage
The toStream method takes a compute and returns a Kefir stream instance.
var canStream = require("can-stream-kefir");
canStream.toStream(compute) //-> stream
For example:
Converting a compute to a stream
var canCompute = require("can-compute");
var canStream = require("can-stream-kefir");
var compute = canCompute(0);
var stream = canStream.toStream(compute);
stream.onValue(function(newVal){
console.log(newVal);
});
compute(1);
//-> console.logs 1