Event

trait Event[+T] extends ReSource with EventCompat[T] with InterpMacro[Option[T]] with Disconnectable

Events only propagate a value when they are changing, when the system is at rest, events have no values.

Note: We hide implicit parameters of the API in the documentation. They are used to ensure correct creation, and you normally do not have to worry about them, except if you accidentally call the implicit parameter list, in which cas you may get cryptic errors. This is a scala limitation. We also hide the internal state parameter of passed and returned events.

Type Params
S

Internal rescala.core.Structure of state.

T

Value type of the event occurrences.

trait InterpMacro[Option[T]]
trait MacroAccess[Option[T], Interp[Option[T]]]
trait EventCompat[T]
trait Interp[Option[T]]
trait ReSource
class Object
trait Matchable
class Any
class EventImpl[T]
class Evt[T]

Document{}

final
def +=(handler: T => Unit)(implicit ticket: CreationTicket): Observe

Adds an observer.

Adds an observer.

See also

observe

final
def \[U](except: Event[U])(implicit ticket: CreationTicket): Event[T]

Propagates the event only when except does not fire.

Propagates the event only when except does not fire.

final
def and[U, R](other: Event[U])(merger: (T, U) => R)(implicit ticket: CreationTicket): Event[R]

Merge the event with the other, if both fire simultaneously.

Merge the event with the other, if both fire simultaneously.

@compileTimeOnly(_root_.scala.StringContext.apply("", " apply can only be used inside of reactive expressions").s(this))
final
def apply(): Option[T]

Makes the enclosing reactive expression depend on the current value of the reactive. Is an alias for value.

Makes the enclosing reactive expression depend on the current value of the reactive. Is an alias for value.

See also

value

Inherited from
MacroAccess
final
def collect[U](expression: PartialFunction[T, U])(implicit ticket: CreationTicket): Event[U]

Collects the results from a partial function

Collects the results from a partial function

Inherited from
EventCompat
final
def count()(implicit ticket: CreationTicket): Signal[Int]

Counts the occurrences of the event. The argument of the event is discarded. Always starts from 0 when the count is created (no matter how often the event has activated in the past).

Counts the occurrences of the event. The argument of the event is discarded. Always starts from 0 when the count is created (no matter how often the event has activated in the past).

final
def dropParam(implicit ticket: CreationTicket): Event[Unit]

Drop the event parameter; equivalent to map((_: Any) => ())

Drop the event parameter; equivalent to map((_: Any) => ())

final
def filter(expression: T => Boolean)(implicit ticket: CreationTicket): Event[T]

Filters the event, only propagating the value when the filter is true.

Filters the event, only propagating the value when the filter is true.

Inherited from
EventCompat
final
def flatten[R](implicit flatten: Flatten[Event[T], R]): R

Flattens the inner value.

Flattens the inner value.

final
def fold[A](init: A)(op: (A, T) => A)(implicit ticket: CreationTicket): Signal[A]

Folds events with a given operation to create a Signal.

Folds events with a given operation to create a Signal.

Inherited from
EventCompat
override
def interpret(v: Value): Option[T]

Interprets the pulse of the event by converting to an option

Interprets the pulse of the event by converting to an option

Definition Classes
final
def iterate[A](init: A)(f: A => A)(implicit ticket: CreationTicket): Signal[A]

Applies a function on the current value of the signal every time the event occurs, starting with the init value before the first event occurrence

Applies a function on the current value of the signal every time the event occurs, starting with the init value before the first event occurrence

final
def last[A >: T](n: Int)(implicit ticket: CreationTicket): Signal[LinearSeq[A]]

Returns a signal which holds the last n events in a list. At the beginning the list increases in size up to when n values are available

Returns a signal which holds the last n events in a list. At the beginning the list increases in size up to when n values are available

final
def latest[A >: T](init: A)(implicit ticket: CreationTicket): Signal[A]

returns a signal holding the latest value of the event.

returns a signal holding the latest value of the event.

Value Params
init

initial value of the returned signal

final
def latest[A >: T]()(implicit ticket: CreationTicket): Signal[A]

returns a signal holding the latest value of the event.

returns a signal holding the latest value of the event.

final
def latestOption[A >: T]()(implicit ticket: CreationTicket): Signal[Option[A]]

Holds the latest value of an event as an Option, None before the first event occured

Holds the latest value of an event as an Option, None before the first event occured

final
def list[A >: T]()(implicit ticket: CreationTicket): Signal[List[A]]

collects events resulting in a variable holding a list of all values.

collects events resulting in a variable holding a list of all values.

final
def map[A](expression: T => A)(implicit ticket: CreationTicket): Event[A]

Transform the event.

Transform the event.

Inherited from
EventCompat
final
def observe(onValue: T => Unit, onError: Throwable => Unit, fireImmediately: Boolean)(implicit ticket: CreationTicket): Observe

Add an observer.

Add an observer.

Returns

the resulting rescala.operator.Observing.Observe can be used to remove the observer.

final
def reduce[A](reducer: (=> A, => T) => A)(implicit ticket: CreationTicket): Signal[A]

reduces events with a given reduce function to create a Signal

reduces events with a given reduce function to create a Signal

final
def toggle[A](a: Signal[A], b: Signal[A])(implicit ticket: CreationTicket): Signal[A]

Switch back and forth between two signals on occurrence of event e

Switch back and forth between two signals on occurrence of event e

@compileTimeOnly("value can only be used inside of reactive expressions")
final
def value: Option[T]

Makes the enclosing reactive expression depend on the current value of the reactive. Is an alias for rescala.macros.MacroAccess.apply.

Makes the enclosing reactive expression depend on the current value of the reactive. Is an alias for rescala.macros.MacroAccess.apply.

See also

apply

Inherited from
MacroAccess
final
def zip[U](other: Event[U])(implicit ticket: CreationTicket): Event[(T, U)]

Merge the event with the other into a tuple, if both fire simultaneously.

Merge the event with the other into a tuple, if both fire simultaneously.

See also

and

final
def zipOuter[U](other: Event[U])(implicit ticket: CreationTicket): Event[(Option[T], Option[U])]

Merge the event with the other into a tuple, even if only one of them fired.

Merge the event with the other into a tuple, even if only one of them fired.

final
def ||[U >: T](other: Event[U])(implicit ticket: CreationTicket): Event[U]

Events disjunction. Propagates the values if any of the events fires. Only propagates the left event if both fire.

Events disjunction. Propagates the values if any of the events fires. Only propagates the left event if both fire.

Type members

Inherited types

type Value
Inherited from
ReSource

Value members

Concrete methods

final
def recover[R >: T](onFailure: PartialFunction[Throwable, Option[R]])(implicit ticket: CreationTicket): Event[R]

Uses a partial function onFailure to recover an error carried by the event into a value when returning Some(value), or filters the error when returning None

Uses a partial function onFailure to recover an error carried by the event into a value when returning Some(value), or filters the error when returning None

def resource: Interp[Option[T]]

Inherited methods

def disconnect()(implicit engine: Scheduler): Unit
Inherited from
Disconnectable

Implicits

Implicits

implicit