Module Lwt_react.E
include module type of React.E
type 'a t = 'a React.eventval never : 'a React.eventval create : unit -> 'a React.event * (?step:React.step -> 'a -> unit)val retain : 'a React.event -> (unit -> unit) -> [ `R of unit -> unit ]val stop : ?strong:bool -> 'a React.event -> unitval equal : 'a React.event -> 'a React.event -> boolval trace :
?iff:bool React.signal ->
('a -> unit) ->
'a React.event ->
'a React.eventval once : 'a React.event -> 'a React.eventval drop_once : 'a React.event -> 'a React.eventval app : ('a -> 'b) React.event -> 'a React.event -> 'b React.eventval map : ('a -> 'b) -> 'a React.event -> 'b React.eventval stamp : 'b React.event -> 'a -> 'a React.eventval filter : ('a -> bool) -> 'a React.event -> 'a React.eventval fmap : ('a -> 'b option) -> 'a React.event -> 'b React.eventval diff : ('a -> 'a -> 'b) -> 'a React.event -> 'b React.eventval changes : ?eq:('a -> 'a -> bool) -> 'a React.event -> 'a React.eventval on : bool React.signal -> 'a React.event -> 'a React.eventval when_ : bool React.signal -> 'a React.event -> 'a React.eventval dismiss : 'b React.event -> 'a React.event -> 'a React.eventval until : 'a React.event -> 'b React.event -> 'b React.eventval accum : ('a -> 'a) React.event -> 'a -> 'a React.eventval fold : ('a -> 'b -> 'a) -> 'a -> 'b React.event -> 'a React.eventval select : 'a React.event list -> 'a React.eventval merge : ('a -> 'b -> 'a) -> 'a -> 'b React.event list -> 'a React.eventval switch : 'a React.event -> 'a React.event React.event -> 'a React.eventval fix : ('a React.event -> 'a React.event * 'b) -> 'bval l1 : ('a -> 'b) -> 'a React.event -> 'b React.eventval l2 : ('a -> 'b -> 'c) -> 'a React.event -> 'b React.event -> 'c React.eventval l3 :
('a -> 'b -> 'c -> 'd) ->
'a React.event ->
'b React.event ->
'c React.event ->
'd React.eventval l4 :
('a -> 'b -> 'c -> 'd -> 'e) ->
'a React.event ->
'b React.event ->
'c React.event ->
'd React.event ->
'e React.eventval l5 :
('a -> 'b -> 'c -> 'd -> 'e -> 'f) ->
'a React.event ->
'b React.event ->
'c React.event ->
'd React.event ->
'e React.event ->
'f React.eventval l6 :
('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g) ->
'a React.event ->
'b React.event ->
'c React.event ->
'd React.event ->
'e React.event ->
'f React.event ->
'g React.eventmodule Option : sig ... endLwt-specific utilities
with_finaliser f e returns an event e' which behave as e, except that f is called when e' is garbage collected.
next e returns the next occurrence of e.
Avoid trying to create an “asynchronous loop” by calling next e again in a callback attached to the promise returned by next e:
- The callback is called within the React update step, so calling
next ewithin it will return a promise that is fulfilled with the same value as the current occurrence. - If you instead arrange for the React update step to end (for example, by calling
Lwt.pause ()within the callback), multiple React update steps may occur before the callback callsnext eagain, so some occurrences can be effectively “lost.”
To robustly asynchronously process occurrences of e in a loop, use to_stream e, and repeatedly call Lwt_stream.next on the resulting stream.
limit f e limits the rate of e with f.
For example, to limit the rate of an event to 1 per second you can use: limit (fun () -> Lwt_unix.sleep 1.0) event.
from f creates an event which occurs each time f () returns a value. If f raises an exception, the event is just stopped.
val to_stream : 'a event -> 'a Lwt_stream.tCreates a stream holding all values occurring on the given event
val of_stream : 'a Lwt_stream.t -> 'a eventof_stream stream creates an event which occurs each time a value is available on the stream.
If updating the event causes an exception at any point during the update step, the exception is passed to !Lwt.async_exception_hook, which terminates the process by default.
delay promise is an event which does not occur until promise resolves. Then it behaves as the event returned by promise.
val keep : 'a event -> unitkeep e keeps a reference to e so it will never be garbage collected.
Threaded versions of React transformation functions
The following functions behave as their React counterpart, except that they take functions that may yield.
As usual the _s suffix is used when calls are serialized, and the _p suffix is used when they are not.
Note that *_p functions may not preserve event order.