当前位置:网站首页>mitt.js:小型事件发布订阅库
mitt.js:小型事件发布订阅库
2022-07-25 04:05:00 【彭世瑜】
Tiny 200b functional event emitter / pubsub.
文档
安装
npm install --save mitt
cdn
<script src="https://unpkg.com/mitt/dist/mitt.umd.js"></script>
使用示例
import mitt from 'mitt'
const emitter = mitt()
function onFoo(data) {
console.log(data);
}
const TOPIC = 'topic'
// 订阅
emitter.on(TOPIC, onFoo)
// 发布事件
emitter.emit(TOPIC, {
a: 'b' })
// 取消订阅
emitter.off(TOPIC, onFoo)
边栏推荐
- Application of AI in testing
- Preparation for Android development in big companies
- GBase JDBC 连接数据库异常
- Apple airpower was forced to cancel its launch two years after it was launched! Uncover the reason!
- LVGL 8.2 Roller
- PCBA scheme design -- Bluetooth intelligent nutrition scale scheme
- Hbuilderx eslint configuration
- SMIC's revenue in 2018 was $3.36 billion, and 14nm technology was mass produced this year
- Construction of data center (I): background of the emergence of data center
- Modbus poll/slave simulator tutorial
猜你喜欢
![[golang from introduction to practice] stone scissors paper game](/img/bb/5a5cdb9228949d263dc7bf62e34d97.png)
[golang from introduction to practice] stone scissors paper game

Analytic hierarchy process of MATLAB

Spirng security (VIII) multiple filter chains coexist
![[interview must brush 101] greedy algorithm, simulation, string](/img/ac/32f249c1884965710d82b8aca0c851.png)
[interview must brush 101] greedy algorithm, simulation, string

Spire. Office for net 7.7.2 and news

Day008 select structure (switch statement)

The LAF protocol elephant of defi 2.0 may be one of the few profit-making means in your bear market

DOM event flow

Maker concept design to adapt to popular education

Do you really understand images? (machine vision)
随机推荐
[cloud picture theory] 248 illustrated public network domain name resolution: easy domain name access to websites / mailboxes
开源之夏专访|“00 后” PMC member 白泽平
Numpy overview
51 single chip microcomputer measures the period of square wave signal
In the Internet of things market, Bosch sensor has launched a number of new solutions
DNS domain name resolution
Leetcode:733. image rendering [BFS]
C language: string processing function
Cannot make qopenglcontext current in a different thread: the solution to pyqt multithread crash
Function and technical principle of data desensitization [detailed explanation]
Internship in 2022
How to test cookies
GBase 8a 关于No Suitable Driver 问题
Behind Senma's LP, "Wenzhou Department" is running into the venture capital circle
Wechat applet application development (I)
一般在进行数仓迁移过程中,是如何进行数据测试的?
@ResponseBody注解的总结
Millet 100W fast charging, 50W wireless charging technology exposure! Oppo Shen Yiren responded: boring!
Properties of trees
RGB and SATA function switching module based on Quanzhi rk3568j