Home Reference Source
import Channel from 'rxmq/src/channel.js'
public class | source

Channel

Rxmq channel class

Constructor Summary

Public Constructor
public

constructor(plugins: Array): void

Represents a new Rxmq channel.

Member Summary

Private Members
private

[prop]: *

Hide from esdoc

private

Channel bus

private

channelStream: Observable

Permanent channel bus stream as Observable

private

Instances of subjects

private

Internal set of utilities

Method Summary

Public Methods
public

observe(name: String): Observable

Get an Observable for specific set of topics

public

registerPlugin(plugin: Object): void

Channel plugin registration

public

request(options: Object): AsyncSubject

Do a request that will be replied into returned AsyncSubject Alias for '.request()' that uses single object as params

public

Returns EndlessSubject representing given topic

Public Constructors

public constructor(plugins: Array): void source

Represents a new Rxmq channel. Normally you wouldn't need to instantiate it directly, you'd just work with existing instance.

Params:

NameTypeAttributeDescription
plugins Array

Array of plugins for new channel

Return:

void

Private Members

private [prop]: * source

Hide from esdoc

private channelBus: EndlessReplaySubject source

Channel bus

private channelStream: Observable source

Permanent channel bus stream as Observable

private subjects: Array source

Instances of subjects

private utils: Object source

Internal set of utilities

Public Methods

public observe(name: String): Observable source

Get an Observable for specific set of topics

Params:

NameTypeAttributeDescription
name String

Topic name / pattern

Return:

Observable

Observable for given set of topics

Example:

const channel = rxmq.channel('test');
channel.observe('test.topic')
       .subscribe((res) => { // default Observable subscription
           // handle results
       });

public registerPlugin(plugin: Object): void source

Channel plugin registration

Params:

NameTypeAttributeDescription
plugin Object

Plugin object to apply

Return:

void

public request(options: Object): AsyncSubject source

Do a request that will be replied into returned AsyncSubject Alias for '.request()' that uses single object as params

Params:

NameTypeAttributeDescription
options Object

Request options

options.topic String

Topic name

options.data Any

Request data

options.DefaultSubject Object

Response subject, defaults to AsyncSubject

Return:

AsyncSubject

AsyncSubject that will dispatch the response

Example:

const channel = rxmq.channel('test');
channel.requestTo({
    topic: 'test.topic',
    data: 'test data',
}).subscribe((response) => { // default Observable subscription
    // handle response
});

public subject(name: String): EndlessSubject source

Returns EndlessSubject representing given topic

Params:

NameTypeAttributeDescription
name String

Topic name

Return:

EndlessSubject

EndlessSubject representing given topic

Example:

const channel = rxmq.channel('test');
const subject = channel.subject('test.topic');