Home Reference Source Repository
import WebsocketClient from 'schema-mapper-api/lib/websocketClient.js'
public class | source

WebsocketClient

Low level communication with a store

Constructor Summary

Public Constructor
public

Create a new WebsocketClient instance

Member Summary

Public Members
public

Object holding eventlisteners

public

Server stream

Method Summary

Public Methods
public

off(topic: String, cb: Function)

Unsubscribe from a topic

public

on(topic: String, cb: Function)

Subscribe to a topic

public

sendCommand(action: String, data: Object): Promise

Send a command to the store

public

Send command and forget about it

Public Constructors

public constructor(url: String) source

Create a new WebsocketClient instance

Params:

NameTypeAttributeDescription
url String

The url of the store to connect to

Public Members

public listeners: Object source

Object holding eventlisteners

public serverStream: SockJS source

Server stream

Public Methods

public off(topic: String, cb: Function) source

Unsubscribe from a topic

Params:

NameTypeAttributeDescription
topic String

Event topic

cb Function

Callback that should be unsubscribed

public on(topic: String, cb: Function) source

Subscribe to a topic

Params:

NameTypeAttributeDescription
topic String

Event topic

cb Function

Callback that should be called when the event has happened

public sendCommand(action: String, data: Object): Promise source

Send a command to the store

Params:

NameTypeAttributeDescription
action String

Command action

data Object

Command data

Return:

Promise

public sendCommandAndForget(action: String, data: Object) source

Send command and forget about it

Params:

NameTypeAttributeDescription
action String

Command action

data Object

Command data