Bonsai_proc.EdgeAll the functions in this module incorporate the concept of "edge-triggering", which is the terminology that we use to describe actions that occur when a value changes.
val on_change :
here:lexing_position ->
?sexp_of_model:('a -> Core.Sexp.t) ->
trigger:[ `Before_display | `After_display ] ->
equal:('a -> 'a -> bool) ->
'a Value.t ->
callback:('a -> unit Effect.t) Value.t ->
unit Computation.tWhen given a value and a callback, on_change and on_change' will watch the input variable and call the callback whenever the value changes.
callback is also called when the component is initialized, passing in the first 'a value that gets witnessed.
These functions do not wait for previous calls to callback to complete before calling it again.
val on_change' :
here:lexing_position ->
?sexp_of_model:('a -> Core.Sexp.t) ->
trigger:[ `Before_display | `After_display ] ->
equal:('a -> 'a -> bool) ->
'a Value.t ->
callback:('a option -> 'a -> unit Effect.t) Value.t ->
unit Computation.tThe same as on_change, but the callback function gets access to the previous value that was witnessed.
val lifecycle :
here:lexing_position ->
?on_activate:unit Effect.t Value.t ->
?on_deactivate:unit Effect.t Value.t ->
?before_display:unit Effect.t Value.t ->
?after_display:unit Effect.t Value.t ->
unit ->
unit Computation.tlifecycle is a way to detect when a computation becomes active, inactive, or an event is triggered after every rendering (roughly 60x / second). By depending on this function (with let%sub), you can install events that are scheduled on either case.
When used, the events are scheduled in this order:
and an "after-display" won't occur before an activation, or after a deactivation for a given computation.
val lifecycle' :
here:lexing_position ->
?on_activate:unit Effect.t option Value.t ->
?on_deactivate:unit Effect.t option Value.t ->
?before_display:unit Effect.t option Value.t ->
?after_display:unit Effect.t option Value.t ->
unit ->
unit Computation.tLike lifecycle, but the events are optional values. If the event value is None when the action occurs, nothing will happen
val before_display :
here:lexing_position ->
unit Effect.t Value.t ->
unit Computation.tbefore_display and before_display' are lower-level functions that can be used to register an event to occur once-per-frame (before the vdom is mounted)
val before_display' :
here:lexing_position ->
unit Effect.t option Value.t ->
unit Computation.tval after_display :
here:lexing_position ->
unit Effect.t Value.t ->
unit Computation.tafter_display and after_display' are lower-level functions that can be used to register an event to occur once-per-frame (after each render).
val after_display' :
here:lexing_position ->
unit Effect.t option Value.t ->
unit Computation.tval wait_after_display :
here:lexing_position ->
unit ->
unit Effect.t Computation.twait_after_display is an effect that will complete after the next frame.
module Poll : sig ... end