jquery/jquery — comment on commit 24e416dca36df4b182a612dba37f8b6cdaa25916
File:  line 0
By julianjelfs:

We have a javascript event aggregator component in our application so that unrelated components can publish and subscribe as means of maintaining a loose coupling between the components. We use jQuery custom event binding under the hood to achieve this. There are some rare circumstances where a component must only subscribe to an event if nothing else has subscribed to it. So we implemented a sort of isSubscribed function on our event aggregator. Under the hood this delves into the data("events") to work out the answer. I did this in the full understanding that it was dodgy and that I was running the risk of it breaking but it works for me at the moment and satisfies a requirement. If there were some sort of hasEvent thing, it would also solve my problem. I'm pretty sure I could work out some other way to do it, but for me it's a +1 for hasEvent.