Filter and map in one step.
Filter and map in one step. Takes a PartialFunction. Whenever an event is received, if the PartialFunction is defined at that event, the value returned by applying it will be fired.
Returns a derived EventStream that only fires events that are not equal to the previous event.
Returns a derived EventStream that only fires events that are not equal to the previous event. This can be used to prevent infinite recursion between multiple event streams that are mutually dependent in a consistent manner.
Returns a new EventStream that propagates a subset of the events that this EventStream fires.
Returns a new EventStream that propagates a subset of the events that this EventStream fires.
the predicate function that determines which events will be fired by the new EventStream.
Create a new EventStream that consists of the events of the EventStreams returned by f.
Create a new EventStream that consists of the events of the EventStreams returned by f. f is applied on every event of the original EventStream, and its returned EventStream is used until the next event fired by the original EventStream, at which time the previously returned EventStream is no longer used and a new one is used instead.
the function that is applied for every event to produce the next segment of the resulting EventStream.
Allows one, in a functional manner, to respond to an event while taking into account past events.
Allows one, in a functional manner, to respond to an event while taking into account past events. For every event t, f is called with arguments (u, t), where u is initially the value of the 'initial' parameter, and subsequently the result of the previous application of f. Returns a new EventStream that, for every event t fired by the original EventStream, fires the result of the application of f (which will also be the next value of u passed to it). Often 'u' will be an object representing some accumulated state. For instance, given an EventStream[Int] named 'es', es.foldLeft(0)(_ + _) would return an EventStream that, for every (integer) event fired by es, would fire the sum of all events that have been fired by es.
Registers a listener function to run whenever an event is fired.
Registers a listener function to run whenever an event is fired. The function is held with a WeakReference and a strong reference is placed in the Observing, so the latter determines the function's gc lifetime.
a function to be applied on every event
the object whose gc lifetime should determine that of the function
Returns a Signal whose value is initially the 'init' parameter, and after every event fired by this EventStream, the value of that event.
Returns a Signal whose value is initially the 'init' parameter, and after every event fired by this EventStream, the value of that event.
the initial value of the signal
Returns a new EventStream, that for every event that this EventStream fires, that one will fire an event that is the result of applying 'f' to this EventStream's event.
Returns a new EventStream, that for every event that this EventStream fires, that one will fire an event that is the result of applying 'f' to this EventStream's event.
the function that transforms events fired by this EventStream into events to be fired by the resulting EventStream.
Returns a derived event stream in which event propagation does not happen on the thread firing it and block it.
Returns a derived event stream in which event propagation does not happen on the thread firing it and block it. This is helpful when handling events can be time consuming. The implementation delegates propagation to an actor (scala standard library), so events are handled sequentially.
Returns a derived EventStream that does not fire events during a prior call to fire on the same thread, thus preventing infinite recursion between multiple event streams that are mutually dependent.
Returns a new EventStream that propagates this EventStream's events until the predicate returns false.
Returns a new EventStream that propagates this EventStream's events until the predicate returns false.
the precate function, taking an event as its argument and returning true if event propagation should continue
Returns an EventStream that only fires events that are not followed by another event within period milliseconds.
Returns an EventStream that only fires events that are not followed by another event within period milliseconds. For instance, if you want to display some results in response to the user typing, and you do not want to perform more work than necessary, you may want to wait until the user has not typed anything for a full second.
Returns an EventStream whose tuple-valued events include a function for testing staleness.
Returns an EventStream whose tuple-valued events include a function for testing staleness. The events will be of type (T, ()=>Boolean), where T is the type of the parent event stream; and the tuple will contain the event fired in the parent as well as a function that can be used to test whether that event is outdated because a new event has been fired since then. This is especially useful in conjunction with 'nonblocking', because its actor implementation means that a new event cannot be received until the previous event is finished being handled. The test function is useful because it may be desirable to abort the time-consuming work if a new event has been fired since then. Example usage: for((v, isSuperseded) <- eventStream.zipWithStaleness) { doSomework(); if(!isSuperseded()) doSomeMoreWork() }
Union of two EventStreams.
Union of two EventStreams. Returns a new EventStream that consists of all events fired by both this EventStream and 'that.'
the other EventStream to combine in the resulting EventStream.
Apply a function for every value.
Apply a function for every value. Same as =>>.
Run a block of code for every value
Run a block of code for every value
Forwards values from this Forwardable to a target, for whose type a CanForward exists (in the implicit scope).
Forwards values from this Forwardable to a target, for whose type a CanForward exists (in the implicit scope). This operator is available for right associativity. For example: val time = Var(0) <<: timerTicks // equivalent to: val time = Var(0); timerTicks >> time
the target
Apply a function for every value
Apply a function for every value
Forwards values from this Forwardable to a target, for whose type a CanForward exists (in the implicit scope).
Forwards values from this Forwardable to a target, for whose type a CanForward exists (in the implicit scope).
the forwarding instance
Apply a PartialFunction for every applicable value
Apply a PartialFunction for every applicable value
An EventStream is a source of events (arbitrary values sent to listener functions). You can fire events from it, you can react to events with any behavior, and you can create derived EventStreams, whose events are based on the original EventStream. The API is modeled after the Scala standard library collections framework.
An EventStream is like a collection in the sense that it consists of multiple values. However, unlike actual collections, the values are not available upon request; they occur whenever they occur. Nevertheless, many operations that apply to collections apply to event streams. To react to events, use foreach or foldLeft. To create derived, transformed EventStreams, use map, flatMap, filter, foldLeft, and the | (union) operator. Note that you can of course use for comprehensions as syntactic sugar for many of the above.
Methods that return a new EventStream generally do not require an (implicit) Observing. Instead, the new EventStream itself holds references to the parent EventStream and the event function (which refers to, or is, the function passed in to the method). (As a result, if you derive EventStreams with a function that performs side effects, in order to ensure that the function is not garbage collected you must retain a reference to the resulting EventStream.)
On the other hand, methods which do require an Observing take functions which are expected perform side effects, and therefore do not hold a reference to the function themselves but rather use the Observing for that purpose. As a result, they will remain in memory as long as the Observing object does.
You can also create a Signal from an EventStream using hold.
the type of values fired as events
EventSource