package logtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Logtk.SignalSource

Basic signal for multiple-callbacks Observer

A signal can be used to decouple the (unique) emitter of some event, and (multiple) receivers for this event. The signal is typically created by the emitter (in the same module), and exposed; then, observers can register to the signal and be notified every time an event (a value) is emitted through the signal.

Sourcetype 'a t

Signal of type 'a

Sourceval create : unit -> 'a t

New signal

Sourceval send : 'a t -> 'a -> unit

Trigger the signal

Sourcetype handler_response =
  1. | ContinueListening
  2. | StopListening
Sourceval on : 'a t -> ('a -> handler_response) -> unit

Register a handler to the signal; the handler returns true if it wants to continue being notified, false otherwise

Sourceval on_every : 'a t -> ('a -> _) -> unit

on_every s f calls f on every event signalled on s

Sourceval once : 'a t -> ('a -> 'b) -> unit

Register a handler to be called only once

Sourceval propagate : 'a t -> 'a t -> unit

propagate a b propagates all values of a into b. Cycles are not detected.

Combinators

Sourceval map : 'a t -> ('a -> 'b) -> 'b t
Sourceval filter : 'a t -> ('a -> bool) -> 'a t
Sourceval set_exn_handler : (exn -> unit) -> unit

Set the handler that is called upon an exception in a Signal. The default handler does nothing. If the handler raises an exception, it is not caught!

OCaml

Innovation. Community. Security.