{"id":21900286,"url":"https://github.com/cryptoc1/events.js","last_synced_at":"2025-03-22T05:44:51.647Z","repository":{"id":82170079,"uuid":"73520152","full_name":"Cryptoc1/events.js","owner":"Cryptoc1","description":"Custom Event Manager with built scheduler","archived":false,"fork":false,"pushed_at":"2016-11-16T02:54:26.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-27T06:31:04.372Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://cryptoc1.github.io/events.js/demo.html","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/Cryptoc1.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-11T23:50:32.000Z","updated_at":"2016-11-16T01:30:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb858a48-9af5-4168-9b3b-c8840a151039","html_url":"https://github.com/Cryptoc1/events.js","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/Cryptoc1%2Fevents.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptoc1%2Fevents.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptoc1%2Fevents.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptoc1%2Fevents.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cryptoc1","download_url":"https://codeload.github.com/Cryptoc1/events.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244913004,"owners_count":20530769,"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-28T15:07:11.322Z","updated_at":"2025-03-22T05:44:51.642Z","avatar_url":"https://github.com/Cryptoc1.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Events.js\n\nEvents.js is a library for managing custom events.\n\nIt includes a built-in scheduler for queueing Event Dispatchers, making it easy and familiar to create custom events.\n\n\n### Getting Started\nSnippet from `demo.html`\n\n```html\n\u003cdiv id=\"demo\"\u003e\u003c/div\u003e\n\u003cscript\u003e\n    // add some content after 3 seconds\n    setTimeout(function() {\n        document.getElementById('demo').textContent = 'Demo content!'\n    }, 3000)\n\n    // register the listener\n    Events.on('demo-content-set', function() {\n        window.alert('Content was set! (tick is: ' + Events.scheduler.tick + ')')\n    })\n\n    // schedule a job for track content change\n    Events.scheduler.add(new EventDispatch({\n        name: 'Demo Change Job',\n        event: 'demo-content-set',\n        filter: function() {\n            if (document.getElementById('demo').textContent === 'Demo content!') return true\n        },\n        timing: {\n          hold: 0\n        },\n        recurring: false\n    }))\n\u003c/script\u003e\n```\n\n## Docs\nEvents.js can be used to manage custom event signaling with an API familiar to those you may have used in JavaScript before.\n\nEvents.js API allows you to set as many listeners for a single event, just like `window.addEventListener`.\n\n### API\n`Events.on(event, handler)`\n+ event : The name of the event to listen to\n+ handler : The callback to be called when the event occurs.\n\nRegisters a handler for the specified event.\nThe handler can take any arrangement of arguments (see [`emit`](#emit))\n\n \u003ca name=\"emit\"\u003e\u003c/a\u003e`Events.emit(event[, arg1[, arg2[, ...]]])`\n+ event : The name of the event to emit\n+ params : Arguments to pass to the event handler\n\nEmits the specified event (asynchronously).\n\nAny arguments after `event` will be forwarded to the event handler as an argument list.\n\n\n### Scheduler\n`Events.scheduler.add(eventDispatch)`\n+ eventDispatch : The EventDispatch to add to the scheduler queue\n\nAdds an [EventDispatch](#eventdispatch) to the queue.\n\n\n### EventDispatch\n`new EventDispatch(options)`\n+ options : An object defining how the EventDispatch behaves\n\n```javascript\n{\n    name: String,\n    event: String,\n    filter: Function,\n    timing: {\n      tick: Number,\n      hold: Number\n    },\n    recurring: Boolean\n}\n```\n\n+ name : The name of the EventDispatch (default: `event`)\n+ event : The event to emit (required)\n+ filter : A function that applies logic for emitting the event. When `filter` returns `true`, `event` is emitted by the scheduler.\n+ timing : An object that configures when the `filter` should be applied.\n    + tick : The scheduler tick to apply `filter` after. (default: `0`)\n    + hold : The number of ticks after `tick` to wait before applying `filter`. (default: `0`)\n+ recurring : Whether or not `filter` should be applied every `timing.tick + timing.hold` ticks, or only once. (default: `true`)\n\n`event`, and `filter` are required options.\n\n\u003cbr\u003e\n\u003cbr\u003e\nFor an example of how to use Events.js, see the [demo](https://cryptoc1.github.io/events.js/demo.html)\n\u003cbr\u003e\n\n\u003chr\u003e\n## License\nMIT\n\n\u0026copy; Samuel Steele \u0026lt;@cryptoc1\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptoc1%2Fevents.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptoc1%2Fevents.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptoc1%2Fevents.js/lists"}