当前位置:网站首页>Tiny-emitter.js: a small event subscription and Publishing Library
Tiny-emitter.js: a small event subscription and Publishing Library
2022-07-25 04:32:00 【Pengshiyu】
A tiny (less than 1k) event emitter library
file
install
npm install tiny-emitter --save
Examples of use
import Emitter from 'tiny-emitter'
const emitter = new Emitter()
function handler(data) {
console.log(data);
}
const TOPIC = 'topic'
// subscribe
emitter.on(TOPIC, handler)
// Subscribe only once
emitter.once(TOPIC, handler)
// Release events 1
emitter.emit(TOPIC, {
a: '1' })
// Unsubscribe
emitter.off(TOPIC, handler)
// Release events 2
emitter.emit(TOPIC, {
a: '2' })
边栏推荐
- 一般在进行数仓迁移过程中,是如何进行数据测试的?
- tiny-emitter.js:一个小型的事件订阅发布库
- If the development of the metauniverse still follows the development logic of the Internet, and its end point also follows
- The United States has launched 337 investigations on a number of Chinese companies: Bubugao is full of lying guns!
- Dig deep into data dividends, Intel and industry accelerate the implementation of digital economy
- PHP Baidu qianqianhua installment API
- DOM event flow
- Docker install MySQL 5.7
- Custom dialog (including header and footer)
- Current characteristics of steering gear with great resistance
猜你喜欢

Burpsuite爆破之token值替换

RGB and SATA function switching module based on Quanzhi rk3568j

数据链路层协议 ——— 以太网协议

DNS domain name resolution

盐粒和冰粒分不清

Druid连接池——从0开始坚强的一点点的自学,Druid一点不懂的可以点进来,懂得别点进来,点进来你会嫌我啰嗦的

Kubesphere 3.3.0 offline installation tutorial

LVGL 8.2 Span

Open source summer interview | "after 00" PMC member Bai Zeping

DOM event flow
随机推荐
Aggregate payment meets the needs of various industries to access a variety of payments
[daily question] 731. My schedule II
[cloud picture theory] 248 illustrated public network domain name resolution: easy domain name access to websites / mailboxes
很多时候都是概率
[ CTF 学习 ] CTF 中的隐写集合 —— 图片隐写术
Wechat applet experiment case: simple idiom dictionary
Apache Doris series: in depth understanding of real-time analytical database Apache Doris
[golang from introduction to practice] stone scissors paper game
How to transfer NFT metadata from IPFs to smart contracts
看问题的角度
Implementation of some basic operation codes of string
Understand Huawei's 2018 financial report with one picture
DNS domain name resolution service
PHP Baidu qianqianhua installment API
How to test cookies
After the failure of listing in Hong Kong, tuba rabbit terminated its gem IPO, and the founder responded
Attack and defense world ----- ics-05
LVGL 8.2 Roller
[internship] processing time
Huawei cloud from entry to actual combat | cloud rapid site establishment service and enterprise host security service