Imandrakit.ObserverObserver, to subscribe to some events.
The observer is thread-safe. However, it is recommended that subscribe callbacks either run in a very short time, or queue heavier work on some background Executor_sig.S.
val create : unit -> 'a tval emit : 'a t -> 'a -> unitval emit_lazy : 'a t -> (unit -> 'a) -> unitemit_lazy obs f emits the result of f(), but only calls f() if there's at least one observer to be notified.
Subscribe to the events. The callback can raise Unsubscribe to remove itself.
val subscribe' : 'a t -> ('a -> unit) -> unitSubscribe to the events. The callback can raise Unsubscribe to remove itself.
val n_subscribers : _ t -> intCurrent number of subscribers
val has_subscribers : _ t -> boolIs there any subscriber?
val with_subscribe : 'a t -> ('a -> unit) -> (unit -> 'ret) -> 'retwith_subscribe obs cb f subscribes cb to obs, calls f(), and when f() is done or has raised, it unsubscribes cb.