{"id":15374186,"url":"https://github.com/moteus/lua-eventemitter","last_synced_at":"2025-04-15T15:10:38.179Z","repository":{"id":55136779,"uuid":"58653317","full_name":"moteus/lua-EventEmitter","owner":"moteus","description":"Implement EventEmitter on Lua","archived":false,"fork":false,"pushed_at":"2021-01-07T19:55:01.000Z","size":36,"stargazers_count":9,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T21:37:58.394Z","etag":null,"topics":["event-emitter","lua"],"latest_commit_sha":null,"homepage":null,"language":"Lua","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/moteus.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":"2016-05-12T15:23:01.000Z","updated_at":"2024-11-02T05:14:16.000Z","dependencies_parsed_at":"2022-08-14T13:01:04.335Z","dependency_job_id":null,"html_url":"https://github.com/moteus/lua-EventEmitter","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-EventEmitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-EventEmitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-EventEmitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moteus%2Flua-EventEmitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moteus","download_url":"https://codeload.github.com/moteus/lua-EventEmitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249094932,"owners_count":21211837,"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":["event-emitter","lua"],"created_at":"2024-10-01T13:57:35.708Z","updated_at":"2025-04-15T15:10:38.151Z","avatar_url":"https://github.com/moteus.png","language":"Lua","readme":"# lua-EventEmitter\n[![Build Status](https://travis-ci.org/moteus/lua-EventEmitter.svg?branch=master)](https://travis-ci.org/moteus/lua-EventEmitter)\n[![Coverage Status](https://coveralls.io/repos/github/moteus/lua-EventEmitter/badge.svg?branch=master)](https://coveralls.io/github/moteus/lua-EventEmitter?branch=master)\n[![License](http://img.shields.io/badge/License-MIT-brightgreen.svg)](LICENSE)\n\nImplementation of EventEmitter for Lua.\n\n### Extend 30log class\n\n```Lua\nlocal EE    = require \"EventEmitter\"\nlocal class = require \"30log\"\n\n-- Create wrapper for EventEmitter\nlocal EventEmitter = EE.extend(class('EventEmitter')) do\n\nfunction EventEmitter:init()\n  -- object by default should have `_EventEmitter` property\n  self._EventEmitter = EE.EventEmitter.new{self = self}\nend\n\nend\n\nlocal Window = EventEmitter:extend('Window')\n\nlocal window = Window:new()\n\nwindow:on('resize', function(self, event, w, h)\n  print(self, (\"Resized %dx%d\"):format(w, h))\nend)\n\nwindow:emit('resize', 125, 250)\n```\n\n### Wrap some table with emitter\n```Lua\nlocal EventEmitter = require \"EventEmitter\"\n\nlocal server = {}\n\nEventEmitter.extend_object(server)\n\nserver:on('accept', function() ... end)\n\nserver:emit('accept', host, port)\n```\n\n## Incompatabilities with [EventEmitter2](https://github.com/asyncly/EventEmitter2)\n\n1. Lua version has no defined order of call listners\n2. JS Allow register same function for same event multiple times.\n```JS\nserver.on('A', test);\nserver.on('A', test);\nserver.emit('A')       // `test` called twice\n```\n3. If event has wildcard followed by some value then mult-level wildcard does not works\n```JS\nserver.on('foo.**', test);\nserver.emit('foo.*')       // called\nserver.emit('foo.*.bar')   // not called\n```\n4. In JS Multi-level key in middle of mask does not allo zero match with wildcard event.\n```JS\nserver.on('foo.**.bar', test);\nserver.emit('foo.*')   // not called\nserver.emit('foo.bar') // called\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoteus%2Flua-eventemitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoteus%2Flua-eventemitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoteus%2Flua-eventemitter/lists"}