@smt-lib/observer
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@smt-lib/observer", | ||
"version": "1.0.0", | ||
"description": "swan-observer是一个订阅发布器。", | ||
"version": "1.0.1", | ||
"description": "@smt-lib/observer是一个订阅发布器。", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "directories": { |
@@ -0,15 +1,24 @@ | ||
--- | ||
title: @smt-lib/observer | ||
header: develop | ||
nav: extensions | ||
sidebar: @smt-lib/observer | ||
--- | ||
**解释:** 在小程序开发中,总会遇到事件监听派发的需求,swan-observer是一个订阅发布器。 | ||
## smt-lib-observer | ||
**解释:** 在小程序开发中,总会遇到事件监听派发的需求,smt-lib-observer是一个订阅发布器。 | ||
#### swan-observer | ||
小程序种使用三方npm包方法,见<a href="https://smartprogram.baidu.com/docs/develop/framework/custom-component_trdparty/" target="_self" title="npm使用说明">npm使用说明</a> | ||
npm install @baidu/swan-observer | ||
``` | ||
npm install @smt-lib/observer | ||
``` | ||
``` | ||
const eventsEmitter = new EventsEmitter(); | ||
``` | ||
const eventsEmitter = new EventsEmitter(); | ||
实例化之后,获得eventsEmitter对象。 | ||
@@ -91,5 +100,5 @@ | ||
// 订阅发布常规用法 | ||
const eventsEmitter = new EventsEmitter(); | ||
let a = 0; | ||
// 订阅发布常规用法 | ||
const eventsEmitter = new EventsEmitter(); | ||
let a = 0; | ||
eventsEmitter.onMessage('addA', message => { | ||
@@ -96,0 +105,0 @@ a += message.num; |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
279
9072
3
10
1