...

View Full Version : unsubscribing using pubsub



DogDay
12-20-2010, 09:35 PM
Hello,

I am having some issues using $.unsubscribe() when I have two or more instances of like subscribers. Anyone care to take a crack at it, please?

Thanks. same code on GitHUB (https://gist.github.com/749019)



// Given the following namespaced objects

// a widget
Namespace('km.widget.edVolGraph', {

handle: 'undefined',
load: function() {
handle = $.subscribe('xmlFetch', function() {
// do stuff
});
}
});

// a controller
Namespace('km.core', {

url: 'someDir/someFile',
fetch: $.get(url, function(xml) {
$.publish('xmlFetch', [xml]);
})
});


// launching the widget
km.widget.edVolGraph.load(); // load into a view on main webpage
km.widget.edVolGraph.load(); // load into a view on main webpage

// if a user wants to kill just one of the views
// how can I unsubscribe that one view without
// unsubscribing the other(s)?

DogDay
12-22-2010, 02:20 PM
Is there no one?

Surely someone can at least tell me if I'm just trying to re-invent the wheel and that I should try x method?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum