package incr_select
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=52848ff15a1636c24b3ad79be99a4324c48341a928bc38cd3bbbd4a1a65c1134
md5=d00eb011ede05fdbf39d23243078531b
doc/incr_select/Incr_select/Make/argument-1-Incr/Observer/index.html
Module Incr.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.tinclude Core_kernel.Invariant.S1 with type 'a t := 'a t
val invariant : ('a -> unit) -> 'a t -> unitval observing : 'a t -> 'a incrementalval use_is_allowed : _ t -> boolval value : 'a t -> 'a Core_kernel.Or_error.tvalue t returns the current value of t, or Error if t does not currently have a stable value. In particular, value t will return Error in 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 value in a function that runs during stabilization, one should use map or bind to express the dependence of an incremental computation on an incremental.
val value_exn : 'a t -> 'amodule Update : sig ... endon_update_exn t ~f calls f after the current stabilization and after each subsequent stabilization in which t changes, until disallow_future_use t is called. f will be called at most once per stabilization. Here is a state diagram for the allowable sequences of Update.t's that can be supplied to a particular f:
val disallow_future_use : _ t -> unitdisallow_future_use t causes all future attempts to use t to fail and on_update_exn handlers added to t to never run again. It also causes incremental to treat t as unobserved, and thus stabilize will not maintain the value of t or any of t's descendants that are needed only to maintain t. disallow_future_use raises if called during stabilization.