Module Start.Handle

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.