{"id":19339715,"url":"https://github.com/rubenv/angular-tiny-eventemitter","last_synced_at":"2025-10-08T04:32:06.725Z","repository":{"id":18497021,"uuid":"21693033","full_name":"rubenv/angular-tiny-eventemitter","owner":"rubenv","description":"Tiny event emitter for Angular.JS.","archived":false,"fork":false,"pushed_at":"2017-08-16T11:40:21.000Z","size":24,"stargazers_count":24,"open_issues_count":4,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-10T08:46:25.950Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rubenv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-10T12:16:41.000Z","updated_at":"2018-07-11T12:01:23.000Z","dependencies_parsed_at":"2022-07-30T13:39:32.112Z","dependency_job_id":null,"html_url":"https://github.com/rubenv/angular-tiny-eventemitter","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fangular-tiny-eventemitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fangular-tiny-eventemitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fangular-tiny-eventemitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fangular-tiny-eventemitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubenv","download_url":"https://codeload.github.com/rubenv/angular-tiny-eventemitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250357565,"owners_count":21417307,"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-10T03:23:28.792Z","updated_at":"2025-10-08T04:32:01.707Z","avatar_url":"https://github.com/rubenv.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# angular-tiny-eventemitter\n\n\u003e Tiny event emitter for Angular.JS.\n\n[![Build Status](https://travis-ci.org/rubenv/angular-tiny-eventemitter.png?branch=master)](https://travis-ci.org/rubenv/angular-tiny-eventemitter)\n\n## Installation\nAdd angular-tiny-eventemitter to your project:\n\n```\nbower install --save angular-tiny-eventemitter\n```\n\nAdd it to your HTML file:\n\n```html\n\u003cscript src=\"bower_components/angular-tiny-eventemitter/dist/angular-tiny-eventemitter.min.js\"\u003e\u003c/script\u003e\n```\n\nReference it as a dependency for your app module:\n\n```js\nangular.module('myApp', ['rt.eventemitter']);\n```\n\n## Usage\n\nSimply inject it as a service:\n\n```js\nangular.module('myApp').factory('MyType', function (eventEmitter) {\n    function MyType(something) {\n        this.value = something;\n    }\n    \n    // Add event emitter methods to MyType.\n    eventEmitter.inject(MyType);\n\n    return MyType;\n});\n```\n\nYou can then use all the normal event emitter methods:\n\n```js\nangular.module('myApp').controller('TestCtrl', function ($scope, MyType) {\n    var thing = new MyType(123);\n\n    function logTheEvent(arg1, arg2) {\n        console.log('Got event: ' + arg1 + ', ' + arg2);\n    }\n\n    thing.on('event', logTheEvent);\n\n    $scope.$on('$destroy', function () {\n        // Remember to avoid memory leaks!\n        thing.off('event', logTheEvent);\n    });\n\n    thing.emit('event', 4, 8);\n});\n```\n\nAlternatively, you can pass a $scope as the first parameter to on() or once() and the listener will be automatically unregistered if the $scope is destroyed.\n\n```js\nangular.module('myApp').controller('TestCtrl', function ($scope, MyType) {\n    var thing = new MyType(123);\n\n    function logTheEvent(arg1, arg2) {\n        console.log('Got event: ' + arg1 + ', ' + arg2);\n    }\n\n    // Passing $scope will register a $destroy event for you.\n    thing.on($scope, 'event', logTheEvent);\n\n    thing.emit('event', 4, 8);\n});\n```\n\n## License \n\n    (The MIT License)\n\n    Copyright (C) 2014-2016 by Ruben Vermeersch \u003cruben@rocketeer.be\u003e\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in\n    all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n    THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenv%2Fangular-tiny-eventemitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubenv%2Fangular-tiny-eventemitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenv%2Fangular-tiny-eventemitter/lists"}