module Sharp_vdom:sig..end
Say s1 is a signal of first name and last name, so its type is
(string * string) t, and container is a HTML element of type
Dom_html.element Js.t. You can display a message in this element like
this:
let unlink =
vdom container s1 (fun (first_name, last_name) ->
tag "div" |* ("class", "message")
|- text "Hello! You are "
|- (tag "em" |- text (first_name ^ " " ^ last_name))
)
in
(* Rest of your program. *)
(* Calling unlink causes the VDOM to be destroyed. *)
type t
val vdom : Dom_html.element Js.t ->
'a Sharp_core.t -> ('a -> t) -> unit -> unitSharp.Core for more details on that) and binds the returned
VDOM to the given real DOM element. The returned callback can be called to
stop reacting to this signal.type restart_strategy =
| |
Never |
| |
Always |
| |
OnChange |
| |
OnDeepChange |
| |
OnIdentifierChange of |
val node : ?network:(Dom_html.element Js.t -> unit -> unit) ->
?strategy:restart_strategy ->
?id:string -> string -> t list -> t
network is a function called when the actual node is created and whose
returned function is called when the node is destroyed.
strategy is the restart strategy for this node. See restart_strategy.
id allows you to identify a node in order to help the VDOM engine to
distinguish between nodes.
val element : ?network:(Dom_html.element Js.t -> unit -> unit) ->
?strategy:restart_strategy -> ?id:string -> string -> tnode but without children.val tag : ?network:(Dom_html.element Js.t -> unit -> unit) ->
?strategy:restart_strategy -> ?id:string -> string -> telement.val text : ?network:(Dom.text Js.t -> unit -> unit) ->
?strategy:restart_strategy -> string -> tval append_child : t -> t -> tval prepend_child : t -> t -> tval set_attribute : string -> string -> t -> tval clear_attribute : string -> t -> tval (|-) : t -> t -> tappend_child.val (|+) : t -> t list -> tval ( |* ) : t -> string * string -> tset_attribute (sort of.)module Linked:sig..end
val link : ?current:Dom.node Js.t ->
Dom_html.element Js.t -> t -> Linked.t * (unit -> unit)val unlink : ?remove:bool -> Linked.t -> unit -> unit
val diff_and_patch : Dom_html.element Js.t ->
Linked.t -> t -> Linked.t * (unit -> unit)
module Element:sig..end
module E: Element