stampit-event-bus

A simple eventbus interface for stampit.

Stampit Event Bus

Install

npm install --save stampit-event-bus

Usage

var EventBus = require('stampit-event-bus');

var stamp = stampit().compose(EventBus).init(function () {

});

API

Register for an event

on(event, listener)

Listen for a specific event. Returns the current stamp so it is chainable.

this.on('event', function (arg1, arg2) { })

Emit event

emit(event, [arg1, arg2, ...])

Emits a specific event with arguments. Returns stamp so it is chainable.

this.emit('event', arg1, arg2)

Register for an event once

once(event, listener)

Listens for a specific event. Listener will only be executed once. Returns stamp so it is chainable.

this.once('event', function () { // only called once })

Remove Listener

removeListener(listener)

Removes the listener from all events it is attached to. Chainable.

var listener = function () { };

this.on('event', listener);

this.removeListener(listener);

LICENSE

Copyright (C) 2014 Stefan Poeter (Stefan.Poeter[at]cloud-automation.de)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

HomePage

https://github.com/Cloud-Automation/stampit-event-bus

Repository

https://github.com/Cloud-Automation/stampit-event-bus.git


上一篇:stampit-log
下一篇:node-modbus

相关推荐

  • 面试题之Event Loop终极篇

    先上一道常见的笔试题 大家可以先配合下面这个图片思考一下输出顺序及这么运行的原因 图片描述(https://img.javascriptcn.com/104c69f0f75d4c2b7f366...

    1 年前
  • 踩了pointer-events:none的坑

    bug出现: 一前端同事跟我说:你把这段加到全局的css里面 然后,悲剧了,上线后发现我的图片都不能点击了。 bug解决: 情急之下,在所有需要点击的img标签外边都包了一层div,把点击事件...

    2 年前
  • 谈谈React事件机制和未来(react-events)

    (https://img.javascriptcn.com/cadc1922d817cf3302e243762f169c2d) 当我们在组件上设置事件处理器时,React并不会在该DOM元素上直接绑...

    10 个月前
  • 详解JavaScript中的Event Loop(事件循环)

    前言 javascript是一门单线程的非阻塞的脚本语言。 单线程意味着,javascript代码在执行的任何时候,都只有一个主线程来处理所有的任务。这个由最初的用途来决定的:与浏览器交互,需要进行各...

    1 个月前
  • 详细剖析 event 几个基本点

    事件流 当在某个DOM元素上触发事件以后,DOM是如何派发事件并寻找监听器的呢?这个派发过程就是事件流。 事件从Document(有的浏览器是window,总之是最外层根元素)开始,按照物理层级结构,...

    3 个月前
  • 译文:JS事件循环机制(event loop)之宏任务、微任务

    原文标题:《Tasks, microtasks, queues and schedules》 这是一篇谷歌大神文章,写得非常精彩。译者想借这次翻译深入学习一下,由于水平有限,英文好的同学建议直接阅...

    2 年前
  • 让在Vue中使用的EventBus也有生命周期

    最近遇到了vue项目中的性能问题,整个项目不断的进行操作五分钟左右,页面已经很卡,查看页面占用了1.5G内存,经过排查一部分原因,是自己模块使用的eventBus在离开页面未进行off掉。

    2 年前
  • 让事件侦听器连接到节点使用addEventListener

    CommunityTyilo(https://stackoverflow.com/users/1/community)提出了一个问题:Get event listeners attached to n...

    2 年前
  • 被忽略掉的composition event

    最近在学习别人是如何使用Vue来造轮子,因此选择在Vue的 UI框架 Element UI。elinput中有这么一段代码 element在处理输入框的input事件的时候,首先进行了一次判断...

    5 个月前
  • 简洁明了探索浏览器event loop

    前段时间我对于浏览器Event loop中的MacroTask和MicroTask哪个先执行有所困惑,苦于搜索也没有发现很明确的答案,于是决定深入探索浏览器Event loop,现有所愚见,想与大家分...

    1 年前

官方社区

扫码加入 JavaScript 社区