Module 1-Incr.Var
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a t -> Ppx_sexp_conv_lib.Sexp.t
val create : ?use_current_scope:bool -> 'a -> 'a tBy default, a variable is created in
Scope.top, on the theory that its value depends on external stimuli (viaVar.set), not on the current scope. However, in some situations it is useful to supply~use_current_scope:trueto create a variable that is invalidated when the current scope is invalidated, e.g. if one wants to useon_update (watch var) ~f:(function Invalidated -> ... | ...)to remove the external stimulus that was settingvar.It is allowed to do
let t = create aduring stabilization; for that stabilization,watch twill have valuea.
val set : 'a t -> 'a -> unitset t asets the value ofttoa. Outside of stabilization, subsequent calls toVar.value twill seea, but thesetwill not have any effect on incrementals until the next stabilization, at which pointwatch twill take on whatevervalue twas at the start of stabilization, causing incremental recomputation as usual.During a stabilization, calling
setwill behave as ifsetwas called after stabilization finished: the new value will not be seen (byvalue vorwatch v) until after the stabilization finishes.
val watch : 'a t -> 'a incrementalwatch treturns an incremental that tracks the value oft. For a givent, all calls towatch treturn the same incremental.
val value : 'a t -> 'avalue treturns the value most recentlysetfortoutside of stabilization.
val latest_value : 'a t -> 'alatest_value treturns the value most recentlysetfort. It can differ fromvalue tonly during stabilization.