canjs / can-stream-kefir

Stream values into and out of computes
https://canjs.com/doc/can-stream-kefir.html
MIT License
3 stars 2 forks source link

Add streamKefir to namespace #49

Closed bgando closed 6 years ago

bgando commented 7 years ago

This package is used as an example in the Advanced Weather Report:

var person = new can.DefineMap({name: "Justin"});

// Create a stream from person's name
var nameStream = can.streamKefir.toStream(person,".name");

// Every time `.name` changes, increase the count 1.
var nameChangeCountStream = nameStream.scan(function(lastValue){
    return lastValue + 1;
}, 0);

// Log the current nameChangeStream value
nameChangeStream.onValue(function(newValue){
    console.log(newValue);
});

person.name = "Ramiya" // logs 1

person.name = "Payal"  // logs 2

but the example won't work because it is not included in the global namespace.

https://github.com/canjs/can-stream-kefir/blob/master/can-stream-kefir.js#L88