package calculon

  1. Overview
  2. Docs

Module Calculon.SignalSource

Basic signal

Sourcetype 'a t

Signal of type 'a

Sourcetype 'a signal = 'a t
Sourceval create : unit -> 'a t

New signal

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

Trigger the signal

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

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

Sourceval on' : 'a t -> ('a -> 'b Lwt.t) -> unit
Sourceval once : 'a t -> ('a -> 'b Lwt.t) -> 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 filter_map : 'a t -> ('a -> 'b option) -> 'b 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!

Send-only View

Can be used only for sending

Sourcemodule Send_ref : sig ... end
OCaml

Innovation. Community. Security.