pubSub.DataPubSubSystem - ZeMA-gGmbH/NoPE-JS GitHub Wiki

Class: DataPubSubSystem

pubSub.DataPubSubSystem

Default implementation of IDataPubSubSystem

Extends the PubSubSystem by adding the following properties and methods:

  • pushData to push data into the system.
  • pullData to pull data from the system. Will allways return the current data or the default value if no data is present at the given path.
  • patternbasedPullData to pull data with a given pattern. See the example for details.
  • patternBasedPush to push data with a given pattern into the system.
  • If you want to acces the root data please check the property data which will contain the entire data root that has been created.

Hierarchy

Implements

Constructors

constructor

new DataPubSubSystem(options?)

Parameters

Name Type
options Partial<IPubSubOptions> & { generateEmitterType?: () => INopeObservable<any, any, any, IEventAdditionalData> }

Inherited from

PubSubSystem.constructor

Properties

_options

_options: IPubSubOptions

Inherited from

PubSubSystem._options


onIncrementalDataChange

Readonly onIncrementalDataChange: INopeEventEmitter<IIncrementalChange, IIncrementalChange, IIncrementalChange, IEventAdditionalData>

An observable which holds the incremental data change. this will be triggered, if the an emitter (publisher) changes its data. Contains only the last emitted data and the topic

// Describe the required Test:
let pubSubSystem = new PubSubSystemBase({
  generateEmitterType: function () {
    return new NopeEventEmitter() as INopeEventEmitter;
  },
});

// Create a Publisher for the system:
let publisher: INopeEventEmitter = new NopeEventEmitter();

pubSubSystem.register(publisher, {
  mode: "publish",
  schema: {},
  topic: "this/is/a/test",
});

pubSubSystem.onIncrementalDataChange.subscribe(console.log);
publisher.emit("Hello World!"); // Logs the following => {path: "this/is/a/test", data: "Hello World!"}

Author

M.Karkowski

Memberof

IPubSubSystem

Implementation of

IDataPubSubSystem.onIncrementalDataChange

Inherited from

PubSubSystem.onIncrementalDataChange


publishers

Readonly publishers: IMapBasedMergeData<INopeTopicWithDirectAccess<any, any, any>, IPubSubEmitterOptions<ITopicSetContentOptions>, INopeTopicWithDirectAccess<any, any, any>, string>

List containing all publishers.

Author

M.Karkowski

Memberof

IPubSubSystem

Implementation of

IDataPubSubSystem.publishers

Inherited from

PubSubSystem.publishers


subscriptions

Readonly subscriptions: IMapBasedMergeData<INopeTopicWithDirectAccess<any, any, any>, IPubSubEmitterOptions<ITopicSetContentOptions>, INopeTopicWithDirectAccess<any, any, any>, string>

List, containing all subscribers.

Author

M.Karkowski

Memberof

IPubSubSystem

Implementation of

IDataPubSubSystem.subscriptions

Inherited from

PubSubSystem.subscriptions

Accessors

data

get data(): unknown

A Getter to return a COPY of the item. Outside of the system, you'll never receive the original object. It is allways a clone.

Author

M.Karkowski

Memberof

PubSubSystemBase

Returns

unknown

Implementation of

IDataPubSubSystem.data


emitters

get emitters(): Object

List all known Emitters in the System.

Returns

Object

Name Type
publishers { name: string ; schema: INopeDescriptor }[]
subscribers { name: string ; schema: INopeDescriptor }[]

Implementation of

IDataPubSubSystem.emitters

Inherited from

PubSubSystemBase.emitters


options

get options(): IPubSubOptions

Options which describe the Behavior

Author

M.Karkowski

Memberof

IPubSubSystem

Returns

IPubSubOptions

Implementation of

IDataPubSubSystem.options

Inherited from

PubSubSystemBase.options

Methods

dispose

dispose(): void

Unregisters all Emitters and removes all subscriptions of the "onIncrementalDataChange", "publishers" and "subscriptions"

Author

M.Karkowski

Memberof

PubSubSystemBase

Returns

void

Implementation of

IDataPubSubSystem.dispose

Inherited from

PubSubSystem.dispose


emit

emit(eventName, data, options?): void

Emits an Events and all subscribes, where the pattern matches will be informed

Author

M.Karkowski

Memberof

IPubSubSystem

Parameters

Name Type Description
eventName string The Topic.
data any The Data of the Event.
options? ITopicSetContentOptions

Returns

void

Implementation of

IDataPubSubSystem.emit

Inherited from

PubSubSystem.emit


patternBasedPush

patternBasedPush<T>(pattern, data, options?, fast?): void

Option to push data to the system using a pattern see patternBasedPush @ IDataPubSubSystem

Type parameters

Name Type
T unknown

Parameters

Name Type Default value Description
pattern string undefined The pattern (see pubSub)
data T undefined The data to push
options Partial<IEventAdditionalData> {} The options used during pushing the data (see IEventAdditionalData)
fast boolean false If enabled, firstly, the data is pushed, afterwards, we just inform once.

Returns

void

Nothing

Implementation of

IDataPubSubSystem.patternBasedPush


patternbasedPullData

patternbasedPullData<T, D>(pattern, _default?): { data: T ; path: string }[]

Option to pull data from the system with a pattern see patternbasedPullData @ IDataPubSubSystem

Type parameters

Name Type
T unknown
D null

Parameters

Name Type Default value Description
pattern string undefined The pattern (see pubSub)
_default D null The Default object, if data is not present.

Returns

{ data: T ; path: string }[]

Implementation of

IDataPubSubSystem.patternbasedPullData


pullData

pullData<T, D>(topic, _default?): T

Option to pull data from the system see pullData @ IDataPubSubSystem

Type parameters

Name Type
T unknown
D null

Parameters

Name Type Default value Description
topic string undefined the Topic to use.
_default D null The default object, if nothing else is provided

Returns

T

The data. Defined as T

Implementation of

IDataPubSubSystem.pullData


pushData

pushData<T>(path, content, options?): void

Option to push data into the system see pushData @ IDataPubSubSystem

Type parameters

Name Type
T unknown

Parameters

Name Type Description
path string The path of the data.
content T The content of the Data.
options Partial<IEventAdditionalData> The options used during pushing the data (see IEventAdditionalData)

Returns

void

nothing.

Implementation of

IDataPubSubSystem.pushData


register

register(emitter, options): INopeTopicWithDirectAccess<any, any, any>

Function to register an Observable. Please define the Options, to decide whether the data of the observable should be published or subscribed.

Author

M.Karkowski

Memberof

IPubSubSystem

Parameters

Name Type Description
emitter INopeObservable<any, any, any, IEventAdditionalData> The Emitter to consider
options IEventOptions

Returns

INopeTopicWithDirectAccess<any, any, any>

{O}

Implementation of

IDataPubSubSystem.register

Inherited from

PubSubSystem.register


registerSubscription

registerSubscription<T>(topic, subscription): INopeObserver

A Helper, that allows the user to subscribe to changes. Therfore he must transmit

Author

M.Karkowski

Memberof

IPubSubSystem

Type parameters

Name Type Description
T unknown Expected Type of the content

Parameters

Name Type Description
topic string The
subscription IEventCallback<T, ITopicSetContentOptions>

Returns

INopeObserver

{INopeObserver}

Implementation of

IDataPubSubSystem.registerSubscription

Inherited from

PubSubSystem.registerSubscription


toDescription

toDescription(): Object

Describes the Data.

Returns

Object

Name Type
data unknown
publishers { name: string ; schema: INopeDescriptor }[]
subscribers { name: string ; schema: INopeDescriptor }[]

Implementation of

IDataPubSubSystem.toDescription

Overrides

PubSubSystem.toDescription


unregister

unregister(emitter): boolean

Removes an observable of the Pub-Sub-System.

Author

M.Karkowski

Memberof

IPubSubSystem

Parameters

Name Type
emitter INopeObservable<any, any, any, IEventAdditionalData>

Returns

boolean

{boolean}

Implementation of

IDataPubSubSystem.unregister

Inherited from

PubSubSystem.unregister


updateMatching

updateMatching(): void

Internal Match-Making Algorithm. This allowes to Create a predefined List between Publishers and Subscribers. Thereby the Process is speed up, by utilizing this Look-Up-Table

Author

M.Karkowski

Memberof

PubSubSystemBase

Returns

void

Implementation of

IDataPubSubSystem.updateMatching

Inherited from

PubSubSystem.updateMatching


updateOptions

updateOptions(emitter, options): void

Function to update the options and there by the topics of an observable.

Author

M.Karkowski

Memberof

IPubSubSystem

Parameters

Name Type Description
emitter INopeObservable<any, any, any, IEventAdditionalData> The Emitter to consider
options IEventOptions The modified options

Returns

void

Implementation of

IDataPubSubSystem.updateOptions

Inherited from

PubSubSystem.updateOptions

⚠️ **GitHub.com Fallback** ⚠️