Class MessageChannel<T>

  • Type Parameters:
    T - Type of the messages of this channel

    public class MessageChannel<T>
    extends java.lang.Object
    Implements some kind of messenger pattern. Conceptually just a globally accessible EventSource with some logging logic.

    This patterns allows us to reduce coupling between controllers. The mediator pattern implemented by MainDesignerController was starting to become very obnoxious, every controller had to keep a reference to the main controller, and we had to implement several levels of delegation for deeply nested controllers. Centralising message passing into a few message channels also improves debug logging.

    This abstraction is not sufficient to remove the mediator. The missing pieces are the following:

    • Global state of the app: in particular the current language version of the editor, and the current compilation unit, should be exposed globally.
    • Transformation requests: e.g. MainDesignerController.wrapNode(Node) allows to associate a node with its rich-text representation by delegating to the code area. This would be a "two-way" channel.
    Since:
    6.12.0
    Author:
    Clément Fournier
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.reactfx.EventStream<T> messageStream​(boolean alwaysHandle, ApplicationComponent component)
      Returns a stream of messages to be processed by the given component.
      void pushEvent​(ApplicationComponent origin, T content)
      Notifies the listeners of this channel with the given payload.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • messageStream

        public org.reactfx.EventStream<T> messageStream​(boolean alwaysHandle,
                                                        ApplicationComponent component)
        Returns a stream of messages to be processed by the given component.
        Parameters:
        component - Component listening to the channel
        Returns:
        A stream of messages
      • pushEvent

        public void pushEvent​(ApplicationComponent origin,
                              T content)
        Notifies the listeners of this channel with the given payload. In developer mode, all messages are logged. The content may be null.
        Parameters:
        origin - Origin of the message
        content - Message to transmit