externalEvent

inline fun <A> externalEvent(label: String? = null): BroadcastEvent<A>(source)

Constructs a new external BroadcastEvent, which is intended to represent events external to the current Timeline. (See also externalSignal for the Signal variant of this).

Since this is intended to represent external events, it is an anti-pattern to call BroadcastEvent.send from logical code that manipulates Signals and Events.

For example, the following would be an incorrect use of externalEvent:

val someEvent: Event<Int> = ...

val newEvent = externalEvent<Int>()

scope.launch {
someEvent.collect { event ->
if (event % 2 == 0) {
newEvent.send(event * 3)
}
}
}

If using yafrl's FRP state testing utilities, this will confuse the test generator into thinking that newEvent above is an input to the system, and thus can have arbitrary values emitted to it, when in fact this is not the case, and newEvent is entirely dependent on someEvent.

Further, the above can be written much more simply as:

val someEvent: Event<Int> = ...

val newEvent = someEvent
.filter { it % 2 == 0 }
.map { it * 3 }

If you really do need access to a more imperative API, and yafrl does not provide another way of implementing your desired logic, you should use internalBroadcastEvent for any internal events.