package reactiveData

  1. Overview
  2. Docs
Declarative events and signals for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

reactiveData-0.3.1.tbz
sha256=ad73fa0434030cdbff27d8a2140fbb70dd6a09af0d318cd02522a1ce3302dc73
sha512=eece1988c8d60ffcbb714b9384a9bea893f6f4a44c0037395d6b2c43f0d06493377f9ca71f8e9751d2148bdfdc357cd8a5445e8b8ea73dc6b2e6acb3cc17bb5c

doc/reactiveData/ReactiveData/module-type-S/index.html

Module type ReactiveData.SSource

Signature describing a reactive data structure ('a t).

Most functions in S are not safe to call during a React update step.

Sourcetype 'a t

Reactive version of the data container

Sourcetype 'a data

Raw (non-reactive) version of the data container

Sourcetype 'a patch

Patch format

Sourcetype 'a msg =
  1. | Patch of 'a patch
    (*

    Patch p triggers the application of p on the current contents

    *)
  2. | Set of 'a data
    (*

    With Set d, d becomes the new content

    *)

Message format

Sourcetype 'a handle

Handle that permits applying incremental updates

Sourceval empty : 'a t

Empty data structure

Sourceval create : 'a data -> 'a t * 'a handle

Build a container from initial contents. The handle can be used for performing reactive updates.

Sourceval from_event : 'a data -> 'a msg React.E.t -> 'a t

from_event d e is a container whose initial value is d, and which gets updated for every occurrence of e

Sourceval from_signal : ?eq:('a -> 'a -> bool) -> 'a data React.S.t -> 'a t

Convert a React signal into a ReactiveData container.

Whenever the signal changes from value v to value v', we detect the differences between v and v', and perform downstream computation (e.g., for map) only on the new and modified elements.

Sourceval const : 'a data -> 'a t

Produce a constant container

Sourceval patch : 'a handle -> 'a patch -> unit

patch h p applies p on the container corresponding to h

Sourceval set : 'a handle -> 'a data -> unit

set h d sets the contents of the container corresponding to h, disregarding previous contents

Sourceval map_msg : ('a -> 'b) -> 'a msg -> 'b msg

Transform a message

Sourceval map : ('a -> 'b) -> 'a t -> 'b t

map f c applies f on all elements of c, producing a new reactive container c'. Modifying the contents of c leads to modifications of c'. f is applied only on the new or modified elements of c.

Sourceval value : 'a t -> 'a data

Return current contents

Sourceval fold : ('a -> 'b msg -> 'a) -> 'b t -> 'a -> 'a React.signal

fold f c v accumulates the updates on c with f starting from v.

The result is a signal of value f m_n (f ... (f m_1 v)), where m_1 ... m_n are the messages that have been applied since the beginning of fold. m_1 is a pseudo-message Set l, accounting for the contents l of c at the time when accumulation starts.

Sourceval signal : ?eq:('a -> 'a -> bool) -> 'a t -> 'a data React.S.t

Signal corresponding to contents

Sourceval event : 'a t -> 'a msg React.E.t

Event whose occurrences correspond to container updates

OCaml

Innovation. Community. Security.