can.onKeyValue
Used by can-reflect.onKeyValue to listen to when the underlying stream emits either a value
or error
with a new value.
stream[@@can.onKeyValue](key, handler)
can-reflect.onKeyValue will use this function
to listen to when emitted value
s or error
s change.
Notice how the following only logs 3 numbers even though 4 numbers are emitted:
var Kefir = require("can-kefir");
var count = Kefir.sequentially(1000, [1, 2, 2, 3]);
canReflect.onKeyValue(stream, "value", function(newVal){
console.log("new value", newVal);
}); // logs 1, 2, 3
Parameters
- key
{String}
:Either
value
for values emitted by the stream orerror
or error values emitted by the stream. - handler
{function(value)}
:A function handler that will be called when the emitted value changes with the emitted value.