types.nope.IDataPubSubSystem - ZeMA-gGmbH/NoPE-JS GitHub Wiki

Interface: IDataPubSubSystem<AD, I, O>

types.nope.IDataPubSubSystem

A data-based Publish and Subscribe system. Extends IPubSubSystem by providing the the methods and properties:

  • 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.

Author

M.Karkowski

Export

Type parameters

Name Type
AD extends ITopicSetContentOptions = ITopicSetContentOptions
I extends INopeObservable<unknown, unknown, unknown, AD> = INopeObservable<unknown, unknown, unknown, AD>
O extends INopeTopicWithDirectAccess = INopeTopicWithDirectAccess

Hierarchy

Implemented by

Properties

data

Readonly data: unknown

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

Author

M.Karkowski

Memberof

IPubSubSystem


emitters

Readonly emitters: Object

List all known Emitters in the System.

Type declaration

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

Inherited from

IPubSubSystem.emitters


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

Inherited from

IPubSubSystem.onIncrementalDataChange


options

Readonly options: IPubSubOptions

Options which describe the Behavior

Author

M.Karkowski

Memberof

IPubSubSystem

Inherited from

IPubSubSystem.options


publishers

Readonly publishers: IMapBasedMergeData<O, IPubSubEmitterOptions<AD>, O, string>

List containing all publishers.

Author

M.Karkowski

Memberof

IPubSubSystem

Inherited from

IPubSubSystem.publishers


subscriptions

Readonly subscriptions: IMapBasedMergeData<O, IPubSubEmitterOptions<AD>, O, string>

List, containing all subscribers.

Author

M.Karkowski

Memberof

IPubSubSystem

Inherited from

IPubSubSystem.subscriptions

Methods

dispose

dispose(): void

Disposes the Pub-Sub-System.

Author

M.Karkowski

Memberof

IPubSubSystem

Returns

void

Inherited from

IPubSubSystem.dispose


emit

emit(path, 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
path string The Topic.
data any The Data of the Event.
options? Partial<AD>

Returns

void

Inherited from

IPubSubSystem.emit


patternBasedPush

patternBasedPush<T>(pattern, content, options): void

Pushes data to the elements, where the pattern matches.

Author

M.Karkowski

Memberof

IDataPubSubSystem

Type parameters

Name Type
T unknown

Parameters

Name Type Description
pattern string The pattern, which should be used to forward the data. For valid patterns see pattern
content T The content to store in the given path.
options Partial<IEventAdditionalData>

Returns

void


patternbasedPullData

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

A Pattern based Pull. You can provide a mqtt based pattern and receive an array which contains all the data which matches the topic.

Author

M.Karkowski

Memberof

IPubSubSystem

Type parameters

Name Type
T unknown
D null

Parameters

Name Type Description
pattern string The pattern to pull the data from
_default D a default value, o

Returns

{ data: T ; path: string }[]

{{ path: string, data: T }[]}


pullData

pullData<T, D>(path, _default): T

Pull some Data of System. You will allways receive a just a copy. This method prevents you to use a pattern like path. If you want to use patterns please use the "patternbasedPullData"

Author

M.Karkowski

Memberof

IPubSubSystem

Type parameters

Name Type Description
T unknown Expected Type of the return. Defaults to unkown
D null Default Value.

Parameters

Name Type Description
path string
_default D If no data is found => return the default data.

Returns

T

The Expected Type


pushData

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

Function, to push data. Every subscriber will be informed, if pushing the data on the given path will affect the subscribers.

Author

M.Karkowski

Memberof

IPubSubSystem

Type parameters

Name Type Description
T unknown Type which is pushed

Parameters

Name Type Description
path string The Path, on which the data should be changed
content T The content to store in the given path.
options? Partial<IEventAdditionalData> The Options, that will be forwarded to subscribers.

Returns

void


register

register(emitter, options): O

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 I The Emitter to consider
options IEventOptions

Returns

O

{O}

Inherited from

IPubSubSystem.register


registerSubscription

registerSubscription<T>(path, 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
path string The
subscription IEventCallback<T, AD>

Returns

INopeObserver

{INopeObserver}

Inherited from

IPubSubSystem.registerSubscription


toDescription

toDescription(): Object

Lists all publishers and subscribers of the system.

Returns

Object

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

Overrides

IPubSubSystem.toDescription


unregister

unregister(emitter): boolean

Removes an observable of the Pub-Sub-System.

Author

M.Karkowski

Memberof

IPubSubSystem

Parameters

Name Type
emitter I

Returns

boolean

{boolean}

Inherited from

IPubSubSystem.unregister


updateMatching

updateMatching(): void

Helper to manually Trigger an update of the Matching. This will update subscribers and publishers and link them. Normally this is not necessary.

This will build an internal linking (based on the settings) between publishers and subscribers.

Author

M.Karkowski

Memberof

IPubSubSystem

Returns

void

Inherited from

IPubSubSystem.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 I The Emitter to consider
options IEventOptions The modified options

Returns

void

Inherited from

IPubSubSystem.updateOptions

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