Interface IDataPubSubSystem<AD, I, O>

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

Hierarchy

Implemented by

Properties

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: {
    publishers: {
        name: string;
        schema: INopeDescriptor;
    }[];
    subscribers: {
        name: string;
        schema: INopeDescriptor;
    }[];
}

List all known Emitters in the System.

Type declaration

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

Options which describe the Behavior

Author

M.Karkowski

Memberof

IPubSubSystem

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

List containing all publishers.

Author

M.Karkowski

Memberof

IPubSubSystem

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

List, containing all subscribers.

Author

M.Karkowski

Memberof

IPubSubSystem

Methods

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

    Author

    M.Karkowski

    Memberof

    IPubSubSystem

    Parameters

    • path: string

      The Topic.

    • data: any

      The Data of the Event.

    • Optional options: Partial<AD>

    Returns void

  • Pushes data to the elements, where the pattern matches.

    Author

    M.Karkowski

    Memberof

    IDataPubSubSystem

    Type Parameters

    • T = unknown

    Parameters

    • 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

  • 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

    Returns

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

    Memberof

    IPubSubSystem

    Type Parameters

    • T = unknown

    • D = null

    Parameters

    • pattern: string

      The pattern to pull the data from

    • _default: D

      a default value, o

    Returns {
        data: T;
        path: string;
    }[]

  • 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

    Returns

    The Expected Type

    Memberof

    IPubSubSystem

    Type Parameters

    • T = unknown

      Expected Type of the return. Defaults to unkown

    • D = null

      Default Value.

    Parameters

    • path: string
    • _default: D

      If no data is found => return the default data.

    Returns T

  • 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

    • T = unknown

      Type which is pushed

    Parameters

    • path: string

      The Path, on which the data should be changed

    • content: T

      The content to store in the given path.

    • Optional options: Partial<IEventAdditionalData>

      The Options, that will be forwarded to subscribers.

    Returns void

  • 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

    Returns

    {O}

    Memberof

    IPubSubSystem

    Parameters

    Returns O

  • Lists all publishers and subscribers of the system.

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

    • data: any
    • publishers: {
          name: string;
          schema: INopeDescriptor;
      }[]
    • subscribers: {
          name: string;
          schema: INopeDescriptor;
      }[]
  • 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

Generated using TypeDoc