@xmess/binder
v0.1.8
Published
> TODO: description
Downloads
5
Readme
@xmess/binder
Table of contents
Description
Installation
- Installing project dependencies
$ npm i @xmess/binder --save
- Import
BinderPlugin
and add to plugins
import { Xmess } from '@xmess/core';
import { BinderPlugin } from '@xmess/binder';
const xmess = new Xmess('some-id', {
plugins: [
new BinderPlugin(),
],
});
Usage
Without BinderPlugin
const xmess1 = new Xmess('xmess-1');
const xmess2 = new Xmess('xmess-2');
xmess1.channel('some-channel').subscribe((message) => {
// xmess1 isn't receiving messages from global context
});
xmess2.channel('some-channel').publish('some-message');
// xmess2 is sharing messages to global context
With BinderPlugin
import { BinderPlugin } from '@xmess/binder';
const xmess1 = new Xmess('xmess-1', {
plugins: [
new BinderPlugin(),
],
});
const xmess2 = new Xmess('xmess-2', {
plugins: [
new BinderPlugin(),
],
});
xmess1.channel('some-channel').subscribe((message) => {
// xmess1 is receiving messages from global context
});
xmess2.channel('some-channel').publish('some-message');
// xmess1 is sharing messages to global context