{"id":15445510,"url":"https://github.com/scriptnull/dead-simple-event-bus","last_synced_at":"2025-04-04T18:17:41.538Z","repository":{"id":74061861,"uuid":"42720077","full_name":"scriptnull/dead-simple-event-bus","owner":"scriptnull","description":"Dead simple implementation of an event bus ","archived":false,"fork":false,"pushed_at":"2015-09-18T17:11:33.000Z","size":140,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-10T05:35:10.590Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scriptnull.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-18T12:16:24.000Z","updated_at":"2015-09-18T12:16:40.000Z","dependencies_parsed_at":"2023-02-27T16:15:31.145Z","dependency_job_id":null,"html_url":"https://github.com/scriptnull/dead-simple-event-bus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptnull%2Fdead-simple-event-bus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptnull%2Fdead-simple-event-bus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptnull%2Fdead-simple-event-bus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptnull%2Fdead-simple-event-bus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scriptnull","download_url":"https://codeload.github.com/scriptnull/dead-simple-event-bus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226191,"owners_count":20904467,"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-10-01T19:45:08.323Z","updated_at":"2025-04-04T18:17:41.518Z","avatar_url":"https://github.com/scriptnull.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Dead simple event bus that can be used in Browsers and Node.js \n\n## Installation\n\nAvailable via npm \n```bash \nnpm install dead-simple-event-bus \n```\n\n## Public API\n\nIt as 3 methods. \n- add()\n- remove()\n- trigger()\n\nAPI can be used in 3 ways , namely\n- Single event \n- Multiple events with args style \n- Multiple events with array style \n\n## Browser Setup \n```html\n\u003cscript type=\"text/javascript\" src=\"node_modules/dead-simple-event-bus/cli.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"text/javascript\"\u003e\nvar ebSingle = new window.EventBus();\nvar ebArgsStyle = new window.EventBus();\nvar ebArrayStyle = new window.EventBus();\n\u003c/script\u003e\n```\n\n## node module \n```javascript\nvar EventBus = require('dead-simple-event-bus').EventBus;\nvar ebSingle = new EventBus();\nvar ebArgsStyle = new EventBus();\nvar ebArrayStyle = new EventBus();\n```\n\n### Single event \n```javascript\n//event Bus with single event \nebSingle.add('a' , function(a , b ){ console.log(a + ' ' + b ); });\nebSingle.trigger('a' , [ 1 , 2 ]);\nebSingle.remove('a' , function(a , b ){ console.log(a + ' ' + b ); } );\n```\n### Multiple events with args style \n```javascript \nebArgsStyle.add('a' , function(a , b ){ console.log(a + ' ' + b ); } , function(a , b ){ console.log( b + ' ' + a  ); });\nebArgsStyle.trigger('a' , [ 1 , 2 ]);\nebArgsStyle.remove('a' , function(a , b ){ console.log(a + ' ' + b ); } , function(a , b ){ console.log( b + ' ' + a  ); });\n```\n\n### Multiple events with array style \n```javascript \nebArrayStyle.add('a' ,[ function(a , b ){ console.log(a + ' ' + b ); } , function(a , b ){ console.log( b + ' ' + a  ); } ] );\nebArrayStyle.trigger('a' , [ 1 , 2 ]);\nebArrayStyle.remove('a' , [ function(a , b ){ console.log(a + ' ' + b ); } , function(a , b ){ console.log( b + ' ' + a  ); }]);\n```\n\n### Duplicate functions\n__dead-simple-event-bus__ optimizes the event bus by not allowing more than one copy of function to be added.\n\n```javascript \nebSingle.add('a' , function(a , b ){ console.log(a + ' ' + b ); }); // assigns event \nebSingle.add('a' , function(a , b ){ console.log(a + ' ' + b ); }); // avoids assigning and prints message\n```\nBy default , duplicate functions print a message to console and doesn't get addedup again on the event bus. If you want to handle this manually , you could dig a bit into the source and insert a callback. \n\n### Contribution \nMore than welcomed !\n\n### License\n![](https://raw.githubusercontent.com/scriptnull/bagpack/master/GPL.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptnull%2Fdead-simple-event-bus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscriptnull%2Fdead-simple-event-bus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptnull%2Fdead-simple-event-bus/lists"}