-
-
Save timmywil/751754 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get xml file & publish | |
km.core = { | |
url: 'someDir/someFile', | |
fetch: $.get(url, function(xml) { | |
$.publish('xmlFetch', [xml]); | |
}) | |
}; | |
// subscribe to xml file and do stuff | |
km.widget.edVolGraph = { | |
handle: 'undefined', | |
load: function(location) { | |
km.widget.edVolGraph.handle = $.subscribe('xmlFetch', function() { | |
// do stuff | |
}); | |
} | |
}; | |
km.core.fetch(); // publish | |
km.widget.edVolGraph.load('south'); // subscribe | |
km.widget.edVolGraph.load('north'); // subscribe | |
$.unsubscribe(km.widget.edVolGraph.handle); // unsubscribes both! | |
// if a user wants to kill just one of the widgets | |
// how can you unsubscribe that one widget without | |
// unsubscribing the other |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment