pubsub-js
pubsub-js使用消息订阅发布机制用于组件之间传递数据,
理解订阅发布机制
1 2 3 4 5 6
| npm i pubsub-js or yarn add pubsub-js
import PubSub from 'pubsub-js'
|
1 2 3 4 5 6 7 8 9 10 11
|
PubSub.publish('MY TOPIC', data)
const token = PubSub.subscribe('MY TOPIC', (msg,data) => {...})
PubSub.unsubscribe(token);
|