This is the presentation for Composing Events with RxJS an Alt.Net Melbourne Lightning Talk.
An observable that yields and event for consecutive clicks. This can be useful when the change since last event is required.
// Setup observables
var button1 = $("#button1").toObservable("click").Select(function() {
return "Button 1" });
var button2 = $("#button2").toObservable("click").Select(function() {
return "Button 2"; });
// Compose an event
var compose = button1.Merge(button2)
// Zip pairs of events
var compose = compose.Skip(1).Zip(compose, function (result1, result2) {
return result1 + " previously " + result2; });
// Subscribe to, and handle event
compose.Subscribe(function (result) {
var val = $("<li/>").html(result);
val.appendTo($("#results"));
});