public interface Broadcaster
Broadcastable
events (usually newly created Syntax
units).Emitter
Modifier and Type | Method and Description |
---|---|
void |
broadcast(Broadcastable broadcastable)
Broadcasts the given event (syntax unit).
|
<T extends Broadcaster> |
chain(T broadcaster)
Specifies an additional
Broadcaster that should receive broadcasted events after this one has processed it. |
void |
chainBroadcast(Broadcastable broadcastable,
Broadcaster first,
Broadcaster... others)
Broadcasts the given event (syntax unit).
|
void |
cut(Broadcaster broadcaster)
Cuts the given
Broadcaster from the chain so that it will no long receive additional events. |
void broadcast(Broadcastable broadcastable)
broadcastable
- The Broadcastable
syntax unit.void chainBroadcast(Broadcastable broadcastable, Broadcaster first, Broadcaster... others)
This will first call chain(Broadcaster)
on this broadcaster with the given broadcasters, so that all given
broadcasters will be at the end of the chain. Then the broadcast occurs. Afterwards all given broadcasters will be cut
from the chain.
broadcastable
- The Broadcastable
syntax unit.first
- The first broadcaster to chain.others
- Optional additional broadcasters to chain.<T extends Broadcaster> T chain(T broadcaster)
Broadcaster
that should receive broadcasted events after this one has processed it.
If this Broadcaster
is already relaying events to another one then chain will be called on that broadcaster
instead, all the way down the line until the given Broadcaster
is at the bottom of the chain.
There are two main ways to use this method. The first way is that you create a new Broadcaster
instance, either
passing the original broadcaster to the constructor or calling chain on the new broadcaster. Then you use your new
broadcaster in place of the old one. This puts your new broadcaster at the top of the chain. This way is the easiest, but
doesn't work in some scenarios.
The second way is that you call chain on the original broadcaster, passing it a newly created one. This results in the new
broadcaster being at the bottom of the chain instead. When doing it this way, you must call cut(Broadcaster)
on the original broadcaster before your method returns, after you are finished with the
broadcasting. Otherwise your new broadcaster will be left dangling. However this way is required if the broadcasted
events need to pass through Refine
plugin methods. Those methods will not use a broadcaster you place at the top
of the chain so being at the bottom is required. In this scenario prefer to use chainBroadcast(Broadcastable,
Broadcaster, Broadcaster...)
, which will take care of the cutting responsibility.
T
- The type of the broadcaster given.broadcaster
- The inner Broadcaster
.void cut(Broadcaster broadcaster)
Broadcaster
from the chain so that it will no long receive additional events.broadcaster
- The broadcaster to cut.Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.