wya-ps

0.1.8 • Public • Published

wya-ps

npm changelog

Demo

安装

npm install wya-ps --save

使用方法

  • on 订阅
  • once 一次订阅
  • off 取消订阅
  • emit 发布事件
import { Event } from 'wya-ps';
let source = new Event({ a: 2 });
 
// 订阅事件 ,不使用`() => {}`, 使用`function() {}`可以拿到当前对象,进行链式操作
source.on('[event-name]', ({ name }) => {
    console.log(name, this);
});
 
// 订阅listener
source.on(({ name }) => {
    console.log(name, this);
});
 
// 发布事件,第一个值事件,第二个值参数
source.emit('[event-name]', { name: 'wya-ps' }); 
 
// 取消事件订阅
source.off('[event-name]');
 
// 取消订阅listener
source.off();

待开发

。。。

Readme

Keywords

none

Package Sidebar

Install

npm i wya-ps

Weekly Downloads

1

Version

0.1.8

License

MIT

Unpacked Size

34.4 kB

Total Files

13

Last publish

Collaborators

  • wya