0.1.8 • Published 5 years ago

wya-ps v0.1.8

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

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();

待开发

。。。

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago