Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Message

A message which can be delivered to a message handler.

Notes

This class may be subclassed to create complex message types.

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Message(type: string): Message
  • Construct a new message.

    Parameters

    • type: string

      The type of the message.

    Returns Message

Properties

type

type: string

The type of the message.

Notes

The type of a message should be related directly to its actual runtime type. This means that type can and will be used to cast the message to the relevant derived Message subtype.

Accessors

isConflatable

  • get isConflatable(): boolean
  • Test whether the message is conflatable.

    Notes

    Message conflation is an advanced topic. Most message types will not make use of this feature.

    If a conflatable message is posted to a handler while another conflatable message of the same type has already been posted to the handler, the conflate() method of the existing message will be invoked. If that method returns true, the new message will not be enqueued. This allows messages to be compressed, so that only a single instance of the message type is processed per cycle, no matter how many times messages of that type are posted.

    Custom message types may reimplement this property.

    The default implementation is always false.

    Returns boolean

Methods

conflate

  • conflate(other: Message): boolean
  • Conflate this message with another message of the same type.

    Parameters

    • other: Message

      A conflatable message of the same type.

    Returns boolean

    true if the message was successfully conflated, or false otherwise.

    Notes

    Message conflation is an advanced topic. Most message types will not make use of this feature.

    This method is called automatically by the message loop when the given message is posted to the handler paired with this message. This message will already be enqueued and conflatable, and the given message will have the same type and also be conflatable.

    This method should merge the state of the other message into this message as needed so that when this message is finally delivered to the handler, it receives the most up-to-date information.

    If this method returns true, it signals that the other message was successfully conflated and that message will not be enqueued.

    If this method returns false, the other message will be enqueued for normal delivery.

    Custom message types may reimplement this method.

    The default implementation always returns false.

Generated using TypeDoc