{"id":20691360,"url":"https://github.com/metafizzy/ev-emitter","last_synced_at":"2025-04-05T10:09:46.993Z","repository":{"id":3350901,"uuid":"49169225","full_name":"metafizzy/ev-emitter","owner":"metafizzy","description":":bell: Lil' event emitter","archived":false,"fork":false,"pushed_at":"2023-11-25T09:32:22.000Z","size":416,"stargazers_count":66,"open_issues_count":6,"forks_count":14,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-04-27T11:44:40.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metafizzy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-06T23:58:05.000Z","updated_at":"2024-06-18T13:41:22.291Z","dependencies_parsed_at":"2024-06-18T13:41:13.795Z","dependency_job_id":null,"html_url":"https://github.com/metafizzy/ev-emitter","commit_stats":{"total_commits":17,"total_committers":3,"mean_commits":5.666666666666667,"dds":"0.11764705882352944","last_synced_commit":"20fc1368b880e70333a02d4748909bbce887de29"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metafizzy%2Fev-emitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metafizzy%2Fev-emitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metafizzy%2Fev-emitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metafizzy%2Fev-emitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metafizzy","download_url":"https://codeload.github.com/metafizzy/ev-emitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318745,"owners_count":20919484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T23:16:24.763Z","updated_at":"2025-04-05T10:09:46.942Z","avatar_url":"https://github.com/metafizzy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EvEmitter\n\n_Lil' event emitter_ — add a little pub/sub\n\nEvEmitter adds publish/subscribe pattern to a browser class. It's a smaller version of [Olical/EventEmitter](https://github.com/Olical/EventEmitter). That EventEmitter is full featured, widely used, and great. This EvEmitter has just the base event functionality to power the event API in libraries like [Isotope](https://isotope.metafizzy.co), [Flickity](https://flickity.metafizzy.co), [Masonry](https://masonry.desandro.com), and [imagesLoaded](https://imagesloaded.desandro.com).\n\n## API\n\n``` js\n// class inheritence\nclass MyClass extends EvEmitter {}\n\n// mixin prototype\nObject.assign( MyClass.prototype, EvEmitter.prototype );\n\n// single instance\nlet emitter = new EvEmitter();\n```\n\n### on\n\nAdd an event listener.\n\n``` js\nemitter.on( eventName, listener )\n```\n\n+ `eventName` - _String_ - name of the event\n+ `listener` - _Function_\n\n### off\n\nRemove an event listener.\n\n``` js\nemitter.off( eventName, listener )\n```\n\n### once\n\nAdd an event listener to be triggered only once.\n\n``` js\nemitter.once( eventName, listener )\n```\n\n### emitEvent\n\nTrigger an event.\n\n``` js\nemitter.emitEvent( eventName, args )\n```\n\n+ `eventName` - _String_ - name of the event\n+ `args` - _Array_ - arguments passed to listeners\n\n### allOff\n\nRemoves all event listeners.\n\n``` js\nemitter.allOff()\n```\n\n## Code example\n\n``` js\n// create event emitter\nvar emitter = new EvEmitter();\n\n// listeners\nfunction hey( a, b, c ) {\n  console.log( 'Hey', a, b, c )\n}\n\nfunction ho( a, b, c ) {\n  console.log( 'Ho', a, b, c )\n}\n\nfunction letsGo( a, b, c ) {\n  console.log( 'Lets go', a, b, c )\n}\n\n// bind listeners\nemitter.on( 'rock', hey )\nemitter.on( 'rock', ho )\n// trigger letsGo once\nemitter.once( 'rock', letsGo )\n\n// emit event\nemitter.emitEvent( 'rock', [ 1, 2, 3 ] )\n// =\u003e 'Hey', 1, 2, 3\n// =\u003e 'Ho', 1, 2, 3\n// =\u003e 'Lets go', 1, 2, 3\n\n// unbind\nemitter.off( 'rock', ho )\n\nemitter.emitEvent( 'rock', [ 4, 5, 6 ] )\n// =\u003e 'Hey' 4, 5, 6\n```\n\n## Browser support\n\nEvEmitter v2 uses ES6 features like [for...of loops](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) and [class definition](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) as such it supports Chrome 49+, Firefox 45+, Safari 9+, and Edge 13+.\n\nFor older browser support, use [EvEmitter v1](https://github.com/metafizzy/ev-emitter/releases/tag/v1.1.1).\n\n## License\n\nEvEmitter is released under the [MIT License](http://desandro.mit-license.org/). Have at it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetafizzy%2Fev-emitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetafizzy%2Fev-emitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetafizzy%2Fev-emitter/lists"}