GithubHelp home page GithubHelp logo

event-emitter's Introduction

license Build Status npm NPM downloads

English Document

Node的events模块不支持先发布后订阅。正是此库的动机。

全局通用发布-订阅模式。可支持:

  • 1、先发布(or触发事件)后订阅(or注册事件)
  • 2、新增命名空间

快速使用

NPM

npm i -D @careteen/event-emitter
import EventEmitter from '@careteen/event-emitter'

EventEmitter.on('click', function (data) {
  console.log('_default:' + data)
})
EventEmitter.emit('click', 'careteen')
EventEmitter.emit('click', 'lanlan')
// 输出 -> careteen  & lanlan

or CDN

<script src='https://unpkg.com/@careteen/event-emitter/dist/index.js'></script>
<script>
  var EventEmitter = window['@careteen/event-emitter']
  EventEmitter.on('click', function (data) {
    console.log('_default:' + data)
  })
  EventEmitter.emit('click', 'careteen')
  EventEmitter.emit('click', 'lanlan')
  // 输出 -> careteen  & lanlan
</script>

更详细使用请查看API

兼容性

IE9+

使用文档

issue模板

贡献者及指南

clone仓库并引入依赖

git clone [email protected]:careteenL/event-emitter.git
npm install

开始开发:)

...

请编写单元测试覆盖所加功能

npm run test

启动本地服务器编写示例

npm run example

修改package.json README.md CHANGELOG.md版本号,再发布

npm run release

更新日志

计划

event-emitter's People

Contributors

careteenl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.