package mosaic

  1. Overview
  2. Docs

Module Mosaic_mlx.SubSource

Ongoing event interests declared by the application.

The app.subscriptions function is called after every update and returns a subscription value describing which events the application wants to receive. Subscriptions are re-evaluated on each cycle, so they may depend on the current model. Compose multiple subscriptions with Sub.batch.

Sourcetype 'msg t =
  1. | None
    (*

    No subscription. Equivalent to batch [].

    *)
  2. | Batch of 'msg t list
    (*

    Activate all subscriptions in the list.

    *)
  3. | Every of float * unit -> 'msg
    (*

    Every (interval, f) fires f () repeatedly at approximately interval-second intervals.

    *)
  4. | On_tick of dt:float -> 'msg
    (*

    On_tick f fires f ~dt on every render frame, where dt is the elapsed time in seconds since the previous frame.

    *)
  5. | On_key of Event.key -> 'msg option
    (*

    On_key f delivers key events only to the currently focused element. f returns None to ignore an event.

    *)
  6. | On_key_all of Event.key -> 'msg option
    (*

    On_key_all f delivers all key events regardless of focus. f returns None to ignore an event.

    *)
  7. | On_mouse of Event.mouse -> 'msg option
    (*

    On_mouse f delivers mouse events only to the currently focused element.

    *)
  8. | On_mouse_all of Event.mouse -> 'msg option
    (*

    On_mouse_all f delivers all mouse events regardless of focus.

    *)
  9. | On_paste of Event.paste -> 'msg option
    (*

    On_paste f delivers paste events only to the currently focused element.

    *)
  10. | On_paste_all of Event.paste -> 'msg option
    (*

    On_paste_all f delivers all paste events regardless of focus.

    *)
  11. | On_resize of width:int -> height:int -> 'msg
    (*

    On_resize f fires f ~width ~height whenever the terminal is resized.

    *)
  12. | On_focus of 'msg
    (*

    On_focus msg dispatches msg when the terminal window gains focus.

    *)
  13. | On_blur of 'msg
    (*

    On_blur msg dispatches msg when the terminal window loses focus.

    *)

The type for subscriptions.

Sourceval none : 'msg t

none is the empty subscription. Produces no events.

Sourceval batch : 'msg t list -> 'msg t

batch subs is a subscription that activates every subscription in subs.

Sourceval every : float -> (unit -> 'msg) -> 'msg t

every interval f fires f () at approximately interval-second intervals for as long as the subscription is active.

Sourceval on_tick : (dt:float -> 'msg) -> 'msg t

on_tick f fires f ~dt on every rendered frame. dt is the elapsed time in seconds since the previous frame. Use this for animations that must advance at the display frame rate.

Sourceval on_key : (Event.key -> 'msg option) -> 'msg t

on_key f delivers key events to f for the currently focused element. f returns None to ignore an event without dispatching. See also on_key_all.

Sourceval on_key_all : (Event.key -> 'msg option) -> 'msg t

on_key_all f is like on_key but delivers all key events regardless of which element has focus.

Sourceval on_mouse : (Event.mouse -> 'msg option) -> 'msg t

on_mouse f delivers mouse events to f for the currently focused element. See also on_mouse_all.

Sourceval on_mouse_all : (Event.mouse -> 'msg option) -> 'msg t

on_mouse_all f is like on_mouse but delivers all mouse events regardless of focus.

Sourceval on_paste : (Event.paste -> 'msg option) -> 'msg t

on_paste f delivers paste events to f for the currently focused element. See also on_paste_all.

Sourceval on_paste_all : (Event.paste -> 'msg option) -> 'msg t

on_paste_all f is like on_paste but delivers all paste events regardless of focus.

Sourceval on_resize : (width:int -> height:int -> 'msg) -> 'msg t

on_resize f fires f ~width ~height whenever the terminal is resized, reporting the new dimensions in columns and rows.

Sourceval on_focus : 'msg -> 'msg t

on_focus msg dispatches msg when the terminal window gains focus.

Sourceval on_blur : 'msg -> 'msg t

on_blur msg dispatches msg when the terminal window loses focus.

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

map f sub is sub with every produced message transformed by f. Use this to embed child-component subscriptions in a parent subscription.