package incr_select

  1. Overview
  2. Docs

on_update t ~f is similar to Observer.on_update_exn, but it does not cause t to be necessary. Instead of the Initialized update, there are updates for when a node becomes Necessary or Unnecessary. Here is a state diagram for the allowable sequences of Update.t's that can be supplied to a particular f:

        /-----------------------------------------------------\
        |                 /                                   |
        |                 |                                   v
       Start ------> Necessary ----------> Changed ------> Invalidated
        |                | ^             |  ^  |              ^
        |                | |   /---------/  \--/              |
        |                v |   v                              |
        \----------> Unnecessary -----------------------------/

If t gets a new value during a stabilization but is unnecessary at the end of it, f will _not_ be called with Changed, but with Unnecessary if allowed by the transition diagram. I.e. if the prior call to f was with Necessary or Changed, f will be called with Unnecessary. If the prior call to f was with Invalidated or Unnecessary, then f will not be called.

One should typically use Observer.on_update_exn, unless the Unnecessary updates are needed.

type 'a t =
  1. | Necessary of 'a
  2. | Changed of 'a * 'a
    (*

    Changed (old_value, new_value)

    *)
  3. | Invalidated
  4. | Unnecessary
include sig ... end
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.t
OCaml

Innovation. Community. Security.