Skip to content

Instantly share code, notes, and snippets.

@tkissing
Created June 29, 2015 16:46
Show Gist options
  • Save tkissing/79bf521bf364ec6fc25c to your computer and use it in GitHub Desktop.
Save tkissing/79bf521bf364ec6fc25c to your computer and use it in GitHub Desktop.
define(function(require) {
var ko = require('knockout');
function observeEvent(pubsub, options) {
var o = ko.observable();
Object.keys(options).forEach(function(evt) {
var value = options[evt];
pubsub.on(evt, function() {
o(value);
});
});
// return read-only version to discourage bad coding patterns
return ko.computed(function() {
return o();
});
}
return observeEvent;
});
define(function(require) {
var ko = require('knockout');
var pubsub = require('pubsub');
var observe = require('pubsub-observable');
function Model() {
this.isAirRecording = observe(pubsub, {'airrecording:started': true, 'airrecording:stopped': false});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment