Class MessageChannel<T>

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

    public class MessageChannel<T>
    extends 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:

    Since:
    6.12.0
    Author:
    Clément Fournier
    • 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
      • latestMessage

        public org.reactfx.value.Val<T> latestMessage()
      • 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
      • connect

        public org.reactfx.Subscription connect​(MessageChannel<T> source)
        Make it so that this channel pushes all the messages of the given [source]. This can be canceled with the returned subscription.