Module React.E

module E: sig .. end
Event combinators.

Consult their semantics.



Primitive and basics


type 'a t = 'a React.event 
The type for events with occurrences of type 'a.
val never : 'a React.event
A never occuring event. For all t, [never]t = None.
val create : unit -> 'a React.event * ('a -> unit)
create () is a primitive event e and a send function. send v generates an occurrence v of e at the time it is called and triggers an update cycle.

Warning. send must not be executed inside an update cycle.

val retain : 'a React.event -> (unit -> unit) -> [ `R of unit -> unit ]
retain e c keeps a reference to the closure c in e and returns the previously retained value. c will never be invoked.

Raises. Invalid_argument on React.E.never.

val stop : 'a React.event -> unit
stop e stops e from occuring. It conceptually becomes React.E.never and cannot be restarted. Allows to disable effectful events.

Note. If executed in an update cycle the event may still occur in the cycle.

val equal : 'a React.event -> 'a React.event -> bool
equal e e' is true iff e and e' are equal. If both events are different from React.E.never, physical equality is used.
val trace : ?iff:bool React.signal -> ('a -> unit) -> 'a React.event -> 'a React.event
trace iff tr e is e except tr is invoked with e's occurence when iff is true (defaults to S.const true). For all t where [e]t = Some v and [iff]t = true, tr is invoked with v.

Transforming and filtering


val once : 'a React.event -> 'a React.event
once e is e with only its next occurence.
val drop_once : 'a React.event -> 'a React.event
drop_once e is e without its next occurrence.
val app : ('a -> 'b) React.event -> 'a React.event -> 'b React.event
app ef e occurs when both ef and e occur simultaneously. The value is ef's occurence applied to e's one.
val map : ('a -> 'b) -> 'a React.event -> 'b React.event
map f e applies f to e's occurrences.
val stamp : 'b React.event -> 'a -> 'a React.event
stamp e v is map (fun _ -> v) e.
val filter : ('a -> bool) -> 'a React.event -> 'a React.event
filter p e are e's occurrences that satisfy p.
val fmap : ('a -> 'b option) -> 'a React.event -> 'b React.event
fmap fm e are e's occurrences filtered and mapped by fm.
val diff : ('a -> 'a -> 'b) -> 'a React.event -> 'b React.event
diff f e occurs whenever e occurs except on the next occurence. Occurences are f v v' where v is e's current occurrence and v' the previous one.
val changes : ?eq:('a -> 'a -> bool) -> 'a React.event -> 'a React.event
changes eq e is e's occurrences with occurences equal to the previous one dropped. Equality is tested with eq (defaults to structural equality).
val when_ : bool React.signal -> 'a React.event -> 'a React.event
when_ c e is the occurrences of e when c is true.
val dismiss : 'b React.event -> 'a React.event -> 'a React.event
dismiss c e is the occurences of e except the ones when c occurs.
val until : 'a React.event -> 'b React.event -> 'b React.event
until c e is e's occurences until c occurs.

Accumulating


val accum : ('a -> 'a) React.event -> 'a -> 'a React.event
accum ef i accumulates a value, starting with i, using e's functional occurrences.
val fold : ('a -> 'b -> 'a) -> 'a -> 'b React.event -> 'a React.event
fold f i e accumulates e's occurrences with f starting with i.

Combining


val select : 'a React.event list -> 'a React.event
select el is the occurrences of every event in el. If more than one event occurs simultaneously the leftmost is taken and the others are lost.
val merge : ('a -> 'b -> 'a) -> 'a -> 'b React.event list -> 'a React.event
merge f a el merges the simultaneous occurrences of every event in el using f and the accumulator a.

[merge f a el]t = List.fold_left f a (List.filter (fun o -> o <> None) (List.map []t el)).

val switch : 'a React.event -> 'a React.event React.event -> 'a React.event
switch e ee is e's occurrences until there is an occurrence e' on ee, the occurrences of e' are then used until there is a new occurrence on ee, etc..
val fix : ('a React.event -> 'a React.event * 'b) -> 'b
fix ef allows to refer to the value an event had an infinitesimal amount of time before.

In fix ef, ef is called with an event e that represents the event returned by ef delayed by an infinitesimal amount of time. If e', r = ef e then r is returned by fix and e is such that :

Raises. Invalid_argument if e' is directly a delayed event (i.e. an event given to a fixing function).