JS message subscription and publishing to realize communication between components



Specific code implementation:

//Install first
yarn add pubsub-js

import PubSub from 'pubsub-js'

PubSub.publish('zxc', 'hello world');

//Subscription: zxc name must be the same
token = PubSub.subscribe('zxc', (msg, data) => {
    console.log('msg ', msg);
    console.log('data ', data);


This work adoptsCC agreementReprint must indicate the author and the link of this article

Recommended Today

Review of SQL Sever basic command

catalogue preface Installation of virtual machine Commands and operations Basic command syntax Case sensitive SQL keyword and function name Column and Index Names alias Too long to see? Space Database connection Connection of SSMS Connection of command line Database operation establish delete constraint integrity constraint Common constraints NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY DEFAULT […]