package incremental
Module Incremental.ObserverSource
Source
val sexp_of_t :
('a -> Sexplib0.Sexp.t) ->
('w -> Sexplib0.Sexp.t) ->
('a, 'w) t ->
Sexplib0.Sexp.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.
on_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:
/-----------------------------------------------------\
| / |
| | v
Start ------> Initialized ------> Changed ------> Invalidated
^ |
\--/on_update_exn raises if disallow_future_use t was previously called.
After disallow_future_use t:
on_update_exn tandvalue_exn twill raise, andvalue twill returnError.t's on-update handlers will never run again.- At the next call to
stabilize, before recomputing nodes, incremental will marktas unobserved, and mark as unnecessary all nodes that were necessary only to maintaint.