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 Object
Implements some kind of messenger pattern. Conceptually just a globally accessibleEventSourcewith some logging logic.This patterns allows us to reduce coupling between controllers. The mediator pattern implemented by
MainDesignerControllerwas 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 classMessageChannel.Message<T>A message transmitted through aMessageChannel.
-
Constructor Summary
Constructors Constructor Description MessageChannel(LogEntry.Category logCategory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.reactfx.Subscriptionconnect(MessageChannel<T> source)Make it so that this channel pushes all the messages of the given [source].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.voidpushEvent(ApplicationComponent origin, T content)Notifies the listeners of this channel with the given payload.
-
-
-
Constructor Detail
-
MessageChannel
public MessageChannel(LogEntry.Category logCategory)
-
-
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
-
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.
-
-