Some InboxSDK API methods accept reactive streams as arguments. A reactive stream represents a series of values that can resolve repeatedly over time. To use streams, you must include a compatible library in your extension. Supported libraries include Kefir, Bacon.js, and RxJS (Reactive Extensions for Javascript).
// Example using the Kefir library
var stream = Kefir.stream(function(emitter) {
var timer = setInterval(function() {
emitter.emit('foo');
}, 1000);
// Return a function to be called when the stream is unsubscribed from
return function() {
clearInterval(timer);
};
});
stream.take(5).onValue(function(value) {
console.log("received", value);
});
// Prints "received foo" five times each one second apart, and then stops.