@pangtou/mitt
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

PTAdmin 插件库

介绍

基于 https://github.com/developit/mitt 做的修改

安装方式

# npm
npm install @pangtou/mitt

# yarn
yarn install @pangtou/mitt

# pnpm
pnpm add @pangtou/mitt
  • UMD 构建 unpkg 使用
<script src="https://unpkg.com/@pangtou/mitt/dist/pangtou.mitt.umd.cjs"></script>

使用方法

import mitt from '@pangtou/mitt';

type Events = {
    foo: string;
    bar?: number;
};

const emit = mitt<Events>();

// 定义监听事件
emit.on('foo', (e) => {});

// 执行事件
emit.emit('foo', 42);

Package Sidebar

Install

npm i @pangtou/mitt

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

6.81 kB

Total Files

7

Last publish

Collaborators

  • shenlan88