{"id":17508184,"url":"https://github.com/danielkov/evs","last_synced_at":"2025-03-28T21:30:02.993Z","repository":{"id":57231490,"uuid":"76241240","full_name":"danielkov/evs","owner":"danielkov","description":"Fast and flexible ES6 event system.","archived":false,"fork":false,"pushed_at":"2016-12-23T11:36:40.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T09:36:14.197Z","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/danielkov.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":"2016-12-12T09:23:12.000Z","updated_at":"2016-12-13T00:45:17.000Z","dependencies_parsed_at":"2022-09-12T17:01:47.926Z","dependency_job_id":null,"html_url":"https://github.com/danielkov/evs","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/danielkov%2Fevs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Fevs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Fevs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielkov%2Fevs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielkov","download_url":"https://codeload.github.com/danielkov/evs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246103789,"owners_count":20724020,"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-20T04:12:40.557Z","updated_at":"2025-03-28T21:30:02.956Z","avatar_url":"https://github.com/danielkov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![codecov](https://codecov.io/gh/danielkov/evs/branch/master/graph/badge.svg)](https://codecov.io/gh/danielkov/evs) [![Build Status](https://travis-ci.org/danielkov/evs.svg?branch=master)](https://travis-ci.org/danielkov/evs) [![dependencies](https://david-dm.org/danielkov/evs.svg)](https://david-dm.org/danielkov/evs) [![devDependencies Status](https://david-dm.org/danielkov/evs/dev-status.svg)](https://david-dm.org/danielkov/evs?type=dev) [![npm version](https://badge.fury.io/js/evs.svg)](https://badge.fury.io/js/evs) [![Inline docs](http://inch-ci.org/github/danielkov/evs.svg?branch=master)](http://inch-ci.org/github/danielkov/evs)\n\n\n# Read me\n\nThis is an ES6 Event Emitter or Event system, that is fast and flexible and makes use of awesome next generation JavaScript features.\n\n### Installation\n\n```js\n$ npm i --save evs\n```\n\nIf you are planning to use it in the browser, for a while you'll need to compile it with something like Babel to make sure it works for everyone.\n\nIf using it with Node JS, you need to make sure you are running a version which is compatible with the ES2015 features. You may need to run `node --harmony` if it doesn't work for you.\n\n### API\n\n#### .constructor()\n\nCreates a new instance. Example usage:\n\n```js\nconst Evs = require('evs');\n\nlet evs = new Evs();\n```\n\nAs this is an ES6 class, you can also extend it and give it your own functionality:\n\n```js\nclass myEvs extends Evs {\n\tconstructor () {\n\t\tsuper() // This line is required.\n\t}\n\n\t// Namespacing our trigger.\n\n\tdo (name, data) {\n\t\tthis.trigger(name, data);\n\t}\n}\n```\n\nUsing the basic API:\n\n```js\n\nlet evs = new Evs();\n\n// Subscribe to an event:\n\nevs.on('name', myFunc);\n\n// Pass more functions into a single handler:\n\nevs.on('name', myFunc1, myFunc2, myFunc3);\n\n// Use a function for more than one event:\n\nevs.on('name test click', (data) =\u003e {console.log(data)});\n\n// Use an array of functions, or even multiple arrays of multiple functions:\n\nevs.on('name', myFunc1, [myFunc2, myFunc3, [myFunc4, myFunc5]]);\n\n// Subscribe to an event only once (same API as on()):\n\nevs.once('name', myFunc);\n\n// Unsubscribe from an event:\n\nevs.off('name', 1) // This will remove the second handler\n\nevs.off('test') // This will remove all handlers\n\n// Unsub from all events (reset emitter):\n\nevs.ofAll();\n\n// Trigger an event:\n\nevs.trigger('name') // No data\n\nevs.trigger('click', {e: event}); // Object as data\n\n// Trigger multiple events:\n\nevs.trigger('click submit', {e: event});\n\n```\n\n### Testing\n\nTo run test, install dependencies with:\n\n```\nnpm i\n```\n\nAfterwards run\n\n```\nnpm test\n```\n\n### Contribution\n\nIf you have any suggestions feel free to add a PR. Bugfixes and performance improvements are always welcome. :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielkov%2Fevs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielkov%2Fevs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielkov%2Fevs/lists"}