Class MessageChannel<T>
- java.lang.Object
-
- net.sourceforge.pmd.util.fxdesigner.app.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 accessibleEventSource
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: that's exposed through Vals on the
DesignerRoot
- Transformation requests: that's exposed through an
AppServiceDescriptor
- Since:
- 6.12.0
- Author:
- Clément Fournier
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MessageChannel.Message<T>
A message transmitted through aMessageChannel
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.reactfx.value.Val<T>
latestMessage()
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.
-
-
-
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 messagecontent
- Message to transmit
-
-