Is there a standard way in jQuery to publish and subscribe to custom class events? There are countless examples of “custom events” which are always related to some HTML element. But what if the javascript class Person() want’s to publish and fire an event iAmSick which is listened for by a class HealthProfessional()? I guess it could be done with callbacks but isn’t there something like asEvented?
Share
So the short answer is: no. Thre is no “standard way in jQuery to publish and subscribe to custom class events”.
However, if you want to create your own solution, but don’t want to start from scratch, I’d highly recommend that you read Darcy Clarke‘s article:
Library Agnostic Pub/Sub (Publish / Subscribe).