@eccenca/messagebus
Eccenca Message Bus for inter-component and in-app communications.
Last updated 3 years ago by leipert .
GPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @eccenca/messagebus 
SYNC missed versions from official npm registry.

Eccenca Message Bus for inter-component and in-app communications

ecc-messagebus exports a normal rxmq.js instance but with a set of additional functions. For convenience it also exports Rx so that we can use a fixed Rx version in all components.

Using Rx

import {Rx} from 'ecc-messagebus';

var source = Rx.Observable.just(42);

var subscription = source.subscribe(
  function (x) {
    console.log(`Next: ${x}');
  },
  function (err) {
    console.log(`Error: ${err}`);
  },
  function () {
    console.log('Completed');
  });

// => Next: 42
// => Completed

Using request-response

Request-response pattern can be used like so:

import rxmq from 'ecc-messagebus';
// ...
// get channel
const channel = rxmq.channel('yourChannel');
// subscribe to topic
channel.subject('someTopic').subscribe(({data, replySubject}) => {
    // ...
    // use envelop.reply to send response
    replySubject.onNext({some: 'response'});
    replySubject.onCompleted();
});
// ...
// initiate request and handle response as a promise
channel.request({
    topic: 'someTopic',
    data: {test: 'test'},
    timeout: 2000
})
.subscribe((data) => {
    // work with data here
    // ...
},
(err) => {
    // catch and handle error here
    // ...
});

Current Tags

  • 5.0.0                                ...           latest (3 years ago)

1 Versions

  • 5.0.0                                ...           3 years ago
Downloads
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |