{"id":29926563,"url":"https://github.com/ecomfe/mini-event","last_synced_at":"2025-08-02T12:42:10.553Z","repository":{"id":11290339,"uuid":"13702236","full_name":"ecomfe/mini-event","owner":"ecomfe","description":"A simple and dedicated library to provide event related components","archived":false,"fork":false,"pushed_at":"2016-06-30T03:34:47.000Z","size":126,"stargazers_count":18,"open_issues_count":2,"forks_count":7,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-07-22T05:16:57.377Z","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/ecomfe.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":"2013-10-19T14:19:10.000Z","updated_at":"2020-02-26T10:01:36.000Z","dependencies_parsed_at":"2022-08-31T00:00:36.728Z","dependency_job_id":null,"html_url":"https://github.com/ecomfe/mini-event","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ecomfe/mini-event","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fmini-event","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fmini-event/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fmini-event/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fmini-event/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ecomfe","download_url":"https://codeload.github.com/ecomfe/mini-event/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fmini-event/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268392116,"owners_count":24243297,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-08-02T12:42:01.192Z","updated_at":"2025-08-02T12:42:10.493Z","avatar_url":"https://github.com/ecomfe.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mini-event\n\nmini-event是一个简单的工具库，用于为任何系统提供事件相关的功能集，包括：\n\n- 统一的`Event`事件对象。\n- 事件的阻止默认行为（`preventDefault`）、停止冒泡（`stopPropagation`）、阻止后续处理（`stopImmediatePropagation`）功能。\n- 事件的注册、反注册等功能。\n\n## 文档\n\n    cd {mini-event}\n    npm i -g esdoc\n    esdoc -c esdoc.json\n    open doc/index.html\n\n## 事件类型\n\n在mini-event模型中，事件共分为2类。\n\n### 命名事件\n\n命名事件是最普通的事件，指一个带有名字的事件。当使用`.fire(eventName)`方法触发事件时，其中的`eventName`指定事件名称，对应名称符合的命名事件将被触发。\n\n### 全局事件\n\n全局事件是名称为`*`的事件，当任何事件被触发时，全局事件均会被触发。\n\n开发者*不能*直接触发全局事件，使用`.fire('*')`触发全局事件将会得到异常结果。\n\n全局事件**一定**在命名事件均触发完毕后触发。\n\n全局事件触发时，事件对象的`type`属性值为事件的原始名称，而非`*`。\n\n## 事件处理函数\n\n不同类型的事件按以下顺序执行：\n\n1. 依次触发所有命名事件处理函数。\n2. 依次触发所有全局事件处理函数。\n\n以上2步中，每一步对应的所有事件处理函数的执行有如下特征：\n\n1. 触发顺序与事件被注册的顺序相同。\n2. 同一个事件处理函数仅会被触发一次。\n3. 在事件触发过程中，如果一个处理函数A移除了同一事件的另一个处理函数B，且B还未触发，则该处理函数不会在本次触发中被执行。\n3. 如果调用事件对象的`.stopImmediatePropagation()`方法，则后续的处理函数均不会被执行。\n\n当一个命名事件触发时，如果处理函数A在执行时移除了全局事件中的处理函数B，则由于B还未被执行，因此后续的全局事件中的处理函数B将不会再被执行。\n\n如果一个事件在命名事件触发时被执行，则其在全局事件被触发时依旧可能被执行。命名事件与全局事件不存在去重的关系。\n\n## 2.0版本变更\n\n1. 使用ES6重写，需要完整的ES6运行环境或者对应的`polyfill`和编译转换，推荐使用[babel](http://babeljs.io/)进行编译。\n2. 移除`Event.fromDOMEvent`方法。\n3. 移除`EventTarget.enable`方法。\n4. 移除对内联事件处理函数（`onxxx`方法）的支持。\n\n## 2.1版本变更\n\n1. 增加了`dist`目录放置使用UMD编译后的代码。\n2. 内部事件池对象不再从`Object.prototype`继承。\n3. 优化了单元测试、文档生成等npm命令。\n\n## 2.2版本变更\n\n1. `main`模块修改为ES6（以前忘记了- -）。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecomfe%2Fmini-event","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecomfe%2Fmini-event","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecomfe%2Fmini-event/lists"}