Module Incremental.Observer
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> ('w -> Ppx_sexp_conv_lib.Sexp.t) -> ('a, 'w) t -> Ppx_sexp_conv_lib.Sexp.t
include Core_kernel.Invariant.S2 with type ('a, 'b) t := ('a, 'b) t
val invariant : 'a Base__.Invariant_intf.inv -> 'b Base__.Invariant_intf.inv -> ('a, 'b) t Base__.Invariant_intf.inv
val observing : ('a, 'w) t -> ('a, 'w) incremental
val use_is_allowed : (_, _) t -> bool
val value : ('a, _) t -> 'a Core_kernel.Or_error.t
value t
returns the current value oft
, orError
ift
does not currently have a stable value. In particular,value t
will returnError
in the following situations:- in the middle of stabilization.
- if
stabilize
has not been called sincet
was created. - if
disallow_future_use t
has been called. - if
observing t
is invalid.
Rather than using
value
in a function that runs during stabilization, one should usemap
orbind
to express the dependence of an incremental computation on an incremental.
val value_exn : ('a, _) t -> 'a
module Update : sig ... end
val on_update_exn : ('a, _) t -> f:('a Update.t -> unit) -> unit
on_update_exn t ~f
callsf
after the current stabilization and after each subsequent stabilization in whicht
changes, untildisallow_future_use t
is called.f
will be called at most once per stabilization. Here is a state diagram for the allowable sequences ofUpdate.t
's that can be supplied to a particularf
:/-----------------------------------------------------\ | / | | | v Start ------> Initialized ------> Changed ------> Invalidated ^ | \--/
on_update_exn
raises ifdisallow_future_use t
was previously called.
val disallow_future_use : (_, _) t -> unit
disallow_future_use t
causes all future attempts to uset
to fail andon_update_exn
handlers added tot
to never run again. It also causes incremental to treatt
as unobserved, and thusstabilize
will not maintain the value oft
or any oft
's descendants that are needed only to maintaint
.disallow_future_use
raises if called during stabilization.