0.0.6 • Published 5 years ago

blant-notifier v0.0.6

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

BLANT

通知管理器

安装

npm install --save blant-notify

正常使用

import notifier from 'blant-notifier';
var blant={};

// 方法1
new notifier(blant,true); // 参数说明,绑定到的对象,是否开启日志
// 方法2
var no1=new notifier();
var no2=new notifier(null,true);
//no1.emit("pagea", {"blant":"good"});
//no2.emit("pagea", {"blant":"good"});

// 注册
blant.listen("pagea", (data)=>{
	console.log(data);
}, this);

// 使用
blant.emit("pagea", {"blant":"good"});

// 移除
blant.remove('pagea',this);

// 清空
blant.clear();

在 wepy 中使用

// 在 app.wpy 中
import notifier from 'blant-notifier';

constructor() {
	super()
	this.use('requestfix')
	this.use('promisify');
	// 导入组件   参数说明:组件对象,绑定到的对象,是否开启日志
	this.use(notifier, wepy.notifier = {}, true);
}

// 在页面A中
export default class pagea extends wepy.page {
	onLoad() {
		// 移除
		wepy.notifier.remove('pagea',this);
		// 清空
		wepy.notifier.clear();
		// 监听
		wepy.notifier.listen("pagea", (data)=>{
			console.log(data);
		}, this);
	}
}

// 在页面B中
export default class pageb extends wepy.page {
	onLoad() {
		wepy.notifier.emit("pagea", {"blant":"good"});
	}
}

License

MIT.

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago