bquarp v0.5.4 Reactivity.DSL.EventStream View Source
The DSL for distributed reactive programming, specifically, operations applicable to Event Streams.
Link to this section Summary
Functions
Delays each produced item by the given interval.
Filters out values of an Event Stream es
that have already been produced at some point.
Applies a procedure to the values of an Event Stream es
without changing them.
Generally used for side effects.
Filters out the Event Streams values that do not satisfy the given predicate.
Creates an Event Stream from a plain Observable obs
.
Creates an Event Stream from a Signal Observable sobs
and tags it with the given guarantees gs
.
Transforms the Event Stream es
into a Behaviour by adhering to its latest change.
Checks if the given object o
is an Event Stream.
Merges multiple Event Streams together The resulting Event Stream carries the events of all composed Event Streams as they arrived.
Filters out values of an Event Stream es
that are equal to the most recently produced value.
Merges multiple Event Streams together The resulting Event Stream carries the events of all composed Event Streams in a round-robin fashion.
Applies a given binary function f
to the values of an Event Stream es
and its previous result.
Works in the same way as the Enum.scan function
Switches from an intial Event Stream to newly supplied Behaviours.
Switches from one Event Stream to another on an event occurrence.
Link to this section Functions
delay(es, interval) View Source
Delays each produced item by the given interval.
distinct(es) View Source
distinct(es, g) View Source
Filters out values of an Event Stream es
that have already been produced at some point.
If no Guarantee is provided, it does not alter the Event Stream Messages. The consequences of using this operator in this way are left to the developer.
If however a Guarantee g
is provided, it is attached to the resulting Event Stream as its new Guarantee,
replacing any previous ones. This is reflected in the Message Contexts.
This can be considered to be the creation of a new source Signal
with the given Guarantee in a stratified dependency graph.
each(es, proc) View Source
Applies a procedure to the values of an Event Stream es
without changing them.
Generally used for side effects.
filter(es, pred) View Source
filter(es, pred, g) View Source
Filters out the Event Streams values that do not satisfy the given predicate.
The expected function should take one argument, the value of an Observable and return a Boolean: true if the value should be produced, false if the value should be discarded.
If no Guarantee is provided, the merge does not alter the Event Stream Messages. The consequences of using this operator in this way are left to the developer.
If however a Guarantee is provided, it is attached to the resulting Event Stream as its new Guarantee, replacing any previous ones. This is reflected in the Message Contexts. Thus, filtering in this way can be considered to be the creation of a new source Signal with the given Guarantee in a stratified dependency graph.
from_plain_obs(obs) View Source
Creates an Event Stream from a plain Observable obs
.
Attaches the given Guarantee g
to it if provided.
Otherwise attaches the globally defined Guarantee,
which is FIFO (the absence of any Guarantee) by default.
from_plain_obs(obs, g) View Source
from_signal_obs(sobs) View Source
Creates an Event Stream from a Signal Observable sobs
and tags it with the given guarantees gs
.
The assumption here is that the contexts of the Signal Observable have already been attached. The primitive can be used for Guarantees with non-obvious Contexts (other than e.g. counters) the developer might come up with.
Attaches the given Guarantee to it if provided without changing the context. Otherwise attaches the globally defined Guarantee, which is FIFO (the absence of any Guarantee) by default.
from_signal_obs(sobs, gs) View Source
hold(es) View Source
Transforms the Event Stream es
into a Behaviour by adhering to its latest change.
is_event_stream?(o) View Source
Checks if the given object o
is an Event Stream.
merge(signals) View Source
merge(ess, g) View Source
Merges multiple Event Streams together The resulting Event Stream carries the events of all composed Event Streams as they arrived.
If no Guarantee is provided, the merge does not alter the Event Stream Messages. A necessary condition for this operation to be valid then is that the given Event Streams all carry the same Guarantees. The consequences of using this operator in this way are left to the developer.
If however a Guarantee is provided, it is attached to the resulting Event Stream as its new Guarantee, replacing any previous ones. This is reflected in the Message Contexts. Thus, merging in this way can be considered to be the creation of a new source Signal with the given Guarantee in a stratified dependency graph.
novel(es) View Source
novel(es, g) View Source
Filters out values of an Event Stream es
that are equal to the most recently produced value.
If no Guarantee is provided, it does not alter the Event Stream Messages. The consequences of using this operator in this way are left to the developer.
If however a Guarantee is provided, it is attached to the resulting Event Stream as its new Guarantee, replacing any previous ones. This is reflected in the Message Contexts. This can be considered to be the creation of a new source Signal with the given Guarantee in a stratified dependency graph.
rotate(ess) View Source
rotate(ess, g) View Source
Merges multiple Event Streams together The resulting Event Stream carries the events of all composed Event Streams in a round-robin fashion.
Should not be used for Event Streams with known discrepancies in event occurrence frequency, since messages will accumulate and create a memory leak.
If no Guarantee is provided, the merge does not alter the Event Stream Messages. A necessary condition for this operation to be valid then is that the given Event Streams all carry the same Guarantees. The consequences of using this operator in this way are left to the developer.
If however a Guarantee is provided, it is attached to the resulting Event Stream as its new Guarantee, replacing any previous ones. This is reflected in the Message Contexts. Thus, merging in this way can be considered to be the creation of a new source Signal with the given Guarantee in a stratified dependency graph.
scan(es, f, default \\ nil) View Source
Applies a given binary function f
to the values of an Event Stream es
and its previous result.
Works in the same way as the Enum.scan function:
Enum.scan(1..10, fn(x,y) -> x + y end) => [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]
switch(es, he) View Source
Switches from an intial Event Stream to newly supplied Behaviours.
Takes an initial Event Stream es
and a higher-order Event Stream he
carrying Event Streams.
Returns an Event Stream that is at first equal to the initial Event Stream.
Each time the higher order Event Stream emits a new Event Stream,
the returned Event Stream switches to this new Event Stream.
Requires that all Event Streams carry values of the same type and have the same set of consistency guarantees.
until(es1, es2, es) View Source
Switches from one Event Stream to another on an event occurrence.
Takes three Event Streams.
Returns an Event Stream that emits the events of the first Event Stream es1
until an event on the third Event Stream es
occurs,
at which point the resulting Event Stream switches to the second Event Stream es2
.
The value of the switching event is irrelevant.
Requires that both Event Streams have the same set of consistency guarantees and carry values of the same type.