Event

rescala.operator.EventBundle.Event
See theEvent companion object
trait Event[+T] extends MacroAccess[Option[T]], 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 parameters

T

Value type of the event occurrences.

Attributes

Companion
object
Graph
Supertypes
trait MacroAccess[Option[T]]
trait ReadAs[Option[T]]
trait ReSource
class Object
trait Matchable
class Any
Show all
Known subtypes
class Evt[T]

Members list

Grouped members

accessor

final infix def observe(onValue: T => Unit, onError: Throwable => Unit, fireImmediately: Boolean)(implicit ticket: CreationTicket[State]): Disconnectable

Add an observer.

Add an observer.

Attributes

Returns

the resulting rescala.structure.Observe can be used to remove the observer.

final def value: Option[T]

Makes the enclosing reactive expression depend on the current value of the reactive.

Makes the enclosing reactive expression depend on the current value of the reactive.

Attributes

See also

apply

Inherited from:
MacroAccess

Event operators

final infix inline def &&(inline expression: T => Boolean)(implicit ticket: CreationTicket[State]): 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.

Attributes

final inline def collect[U](inline expression: PartialFunction[T, U])(implicit ticket: CreationTicket[State]): Event[U]

Collects the results from a partial function

Collects the results from a partial function

Attributes

final infix def except(exception: Event[Any])(implicit ticket: CreationTicket[State]): Event[T]

Propagates the event only when the other event exception does not fire.

Propagates the event only when the other event exception does not fire.

Attributes

final infix inline def filter(inline expression: T => Boolean)(implicit ticket: CreationTicket[State]): 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.

Attributes

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

Flattens the inner value.

Flattens the inner value.

Attributes

final infix inline def map[B](inline expression: T => B)(implicit ticket: CreationTicket[State]): Event[B]

Transform the event.

Transform the event.

Attributes

final inline def snap[B, T1 >: T](inline expression: B)(using CreationTicket[State])(using T1 =:= Unit): Event[B]

Like map, but allows to ignore the parameter if its type is Unit. Useful for snapshotting some signals when an event triggers

Like map, but allows to ignore the parameter if its type is Unit. Useful for snapshotting some signals when an event triggers

Attributes

final def ||[U >: T](other: Event[U])(implicit ticket: CreationTicket[State]): 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.

Attributes

Event to Signal conversions

final def count()(implicit ticket: CreationTicket[State]): 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).

Attributes

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

returns a signal holding the latest value of the event.

returns a signal holding the latest value of the event.

Value parameters

init

initial value of the returned signal

Attributes

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

returns a signal holding the latest value of the event.

returns a signal holding the latest value of the event.

Attributes

final def holdOption[A >: T]()(implicit ticket: CreationTicket[State]): 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

Attributes

final def iterate[A](init: A)(f: A => A)(implicit ticket: CreationTicket[State]): 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

Attributes

final def list[A >: T](n: Int)(implicit ticket: CreationTicket[State]): 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

Attributes

final def list[A >: T]()(implicit ticket: CreationTicket[State]): 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.

Attributes

final def toggle[A](a: Signal[A], b: Signal[A])(implicit ticket: CreationTicket[State]): 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

Attributes

internal

override def read(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

Attributes

Definition Classes

conversion

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

Folds events with a given operation to create a Signal.

Folds events with a given operation to create a Signal.

Attributes

Type members

Types

type State[V] = BundleState[V]

Inherited types

type Value

Attributes

Inherited from:
ReSource

Value members

Concrete methods

final def recover[R >: T](onFailure: PartialFunction[Throwable, Option[R]])(implicit ticket: CreationTicket[State]): 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

Attributes

Inherited methods

infix inline def act[S](inline f: (FoldState[S]) ?=> T => S): Branch[S]
Extension method from EventBundle

Attributes

Inherited from:
FoldBundle
def disconnect(): Unit

Attributes

Inherited from:
Disconnectable
def info: ReInfo

Attributes

Inherited from:
ReSource

Implicits

Implicits

implicit def internalAccess(v: Value): Pulse[T]