I have issue to unbind one listeners that listen one of shared emitter:
// this is emitter. Fire always in a.b.c namespace but with different parameters
$(document).trigger("a.b.c", {
p: 1,
p2: ...
});
// listener 1
$(document).bind("a.b.c", function(e, object) {
if (object.myParam) {
....
}
});
// listener 2
$(document).bind("a.b.c", function(e, object) {
if (object.anotherParam) {
....
}
});
How to unbind listener 2, so listeners 1 still continue work?
I found better solution Namespaced Events
Now trigging
a.b.cwill trigger withlistener1andlistener2.And to unbind – just unbind with specific listener, like:
In that case
listener2will be preserved, and will be able to invoked via namespacea.b.c