Module Make_with_config.Observer
An observer lets one get the value of an incremental, either by asking directly for the value or installing an on-update handler to run when the incremental's value changes.
One first creates an observer using observe. One must then call stabilize before making any observations on that observer.
Doing let o = observe t causes subsequent calls to stabilize to maintain the value of t, until either:
disallow_future_use ois called, orois garbage collected andohas no on-update handlers.
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a t -> Ppx_sexp_conv_lib.Sexp.t
include Core_kernel.Invariant.S1 with type 'a t := 'a t
val invariant : 'a Base__.Invariant_intf.inv -> 'a t Base__.Invariant_intf.inv
val observing : 'a t -> 'a incrementalval use_is_allowed : _ t -> boolval value : 'a t -> 'a Core_kernel.Or_error.tvalue treturns the current value oft, orErroriftdoes not currently have a stable value. In particular,value twill returnErrorin the following situations:- in the middle of stabilization.
- if
stabilizehas not been called sincetwas created. - if
disallow_future_use thas been called. - if
observing tis invalid.
Rather than using
valuein a function that runs during stabilization, one should usemaporbindto express the dependence of an incremental computation on an incremental.
val value_exn : 'a t -> 'a
module Update : sig ... endon_update_exn t ~fcallsfafter the current stabilization and after each subsequent stabilization in whichtchanges, untildisallow_future_use tis called.fwill 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:
val on_update_exn : 'a t -> f:('a Update.t -> unit) -> unitval disallow_future_use : _ t -> unitdisallow_future_use tcauses all future attempts to usetto fail andon_update_exnhandlers added totto never run again. It also causes incremental to treattas unobserved, and thusstabilizewill not maintain the value oftor any oft's descendants that are needed only to maintaint.disallow_future_useraises if called during stabilization.