This implementation is very lightweight, simple, and powerful.
For advanced developers only.
Here are some key features of "JZ Publish/Subscribe":
· Subscribing
· Unsubscribing
· Publishing
Requirements:
· JavaScript enabled on client side
· jQuery 1.4.3 or higher
What's New in This Release: [ read full changelog ]
New Features:
· Previously, if a callback unsubscribed something from a topic that was still being published, there would be an error because the subscriptions array shrank but the loop still tried to iterate over an array that still had the old length. Now, when $.unsubscribe is called while still publishing, it will queue up the unsubscription to be executed after publishing is finished.
· Handle returned from $.subscribe now includes a context property.
· Context parameter added to $.unsubscribe
Bug Fix:
· $.unsubscribe would unsubscribe a subscription if the topic and callback matched, regardless of whether the context was correct. It now checks the context too.