Skip to content

Commit

Permalink
basics: add client-server build schema
Browse files Browse the repository at this point in the history
  • Loading branch information
balat committed Dec 20, 2023
1 parent 6794c0f commit c46e680
Show file tree
Hide file tree
Showing 2 changed files with 696 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tutos/dev/manual/basics.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,18 @@ PPX annotations allow to split the code into these two programs:

Same for {{{module%shared}}}, {{{open%shared}}}, {{{type%shared}}} etc.

{{@@class="doc-img-col-width"@@files/tutorial/client-server.svg|Client-server build system}}

===Client values===
Fragments of client code can be included in server (or shared) sections.

Example:

<<code language="ocaml" class="server"|
button ~a:[a_onclick [%client fun ev -> ... ]] [ ... ]
>>


Client values can be declared within server or shared code as
{{{[%client[ (<value> : <type>) ]}}}.
The type annotation is almost always required.
Expand Down Expand Up @@ -735,7 +746,7 @@ Attributes like {{{a_onclick}}} in module {{{Eliom_content.Html.D}}} or {{{F}}}
take a client side function as parameter:

<<code language="ocaml" class="shared"|
div ~a:[a_onclick [%client fun ev -> ... ]] [ ... ]
button ~a:[a_onclick [%client fun ev -> ... ]] [ ... ]
>>

Module {{{Lwt_js_events}}} of Js_of_ocaml defines a way to bind browser events
Expand Down
Loading

0 comments on commit c46e680

Please sign in to comment.