Module Useri

module Useri: sig .. end
Simple declarative user interaction with React.

Useri gathers user input as React signals and events from a single rendering surface.

Open the module to use it, this defines only modules in your scope.

Note. Before Useri.App.init is called all signals hold invalid data.

Caveat. Do not expect to be able to fully exploit the possibilities and flexibility of the platforms underlying the backends. This library is a simple abstraction library and thus remains limited by design.

Release 0.0.0-72-g9c6670f — Daniel Bünzli <daniel.buenzl i@erratique.ch>



Useri


module Time: sig .. end
Monotonic time.
module Surface: sig .. end
Rendering surface.
module Mouse: sig .. end
User mouse.
module Touch: sig .. end
User touches.
module Key: sig .. end
User keyboard.
module Text: sig .. end
User textual input and clipboard.
module Drop: sig .. end
User drag and drop.
module Human: sig .. end
Human factors.
module App: sig .. end
Application

Minimal example

This minimal example can be used on both synchronous and asynchronous backends.

Integration with cooperative concurency

A good way of managing side-effects at the boundaries of your functional reactive system is to use a cooperative concurency library and convert event occurences and signal changes to yielding futures/threads (to avoid the problem of forbidden recursive primitive feedback) and convert futures/threads to a primitive event with a single occurence.

You will need however need to cooperate with Useri's event loop and give it a high priority as the ability to interact should never take over a long running computation.

The following code shows how to do that with Lwt and Fut

Input, animation and rendering coordination

The Useri.Time and Useri.Surface modules provide support for coordinating input, animation and rendering. We can distinguish two patterns for rendering:

In both cases rendering is coordinated by the Useri.Surface.refresh event. It is important to use this event for the following reasons: There are various non-exclusive ways of generating occurences of Useri.Surface.refresh: