package bonsai

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type ('input, 'extra, 'incoming, 'outgoing) t

A handle represents a running app, and can be used to schedule external actions, determine if the app has started, and stop the app.

  • 'input is the input type of the outermost component of the app.
  • 'extra is any extra result (other than the app view) returned by the outermost component.
val stop : (_, _, _, _) t -> unit

Stops the application from updating or responding to any actions. The app cannot be restarted. The displayed contents are not removed from the page.

val started : (_, _, _, _) t -> unit Async_kernel.Deferred.t

A deferred that resolves after the first display occurs. At this point, there is content being shown on the screen.

val schedule : (_, _, 'incoming, _) t -> 'incoming -> unit

Schedules an event for an action of type 'incoming. This action gets routed to the Bonsai component that returned its inject function in the App_result.t

val outgoing : (_, _, _, 'outgoing) t -> 'outgoing Async_kernel.Pipe.Reader.t

Returns a pipe containing all of the actions of type 'outgoing that the Bonsai app has scheduled.

val input : ('input, _, _, _) t -> 'input

Returns the value of the current input.

val set_input : ('input, _, _, _) t -> 'input -> unit

Overwrites the current input.

val update_input : ('input, _, _, _) t -> f:('input -> 'input) -> unit

A helper method for fetching the current input and providing an updating function that returns a new input. This is to make functionally updating data structures easier.

val extra : (_, 'extra, _, _) t -> ('extra -> unit) Bus.Read_only.t

A bus containing successive values of extra returned by the app in its App_result.t.

val last_extra : (_, 'extra, _, _) t -> 'extra option

The latest value written to extra, if it exists.