Library
Module
Module type
Parameter
Class
Class type
Web Applications Running in the Browser
Introduction to Web Applications
module Random : sig ... end
Generate Random Numbers
module Time : sig ... end
Posix Time
module Value : sig ... end
Javascript Values
module Event_flag : sig ... end
Event flags to stop propagation and prevent default action.
module Decoder : sig ... end
Decoder for Javascript Values
module Command : sig ... end
Commands to be executed as a result of an update operation.
module Subscription : sig ... end
Subscriptions to global events.
module Attribute : sig ... end
Attributes of Dom Elements.
module Html : sig ... end
Virtual Dom
val sandbox :
'state ->
('state -> 'msg Html.t) ->
('state -> 'msg -> 'state) ->
unit
val element :
string ->
('state * 'msg Command.t) Decoder.t ->
('state -> 'msg Html.t) ->
('state -> 'msg Subscription.t) ->
('state -> 'msg -> 'state * 'msg Command.t) ->
unit
element my_app init view subs update
Create a browser application named my_app
on the javascript side. The application creates the global object named my_app
which contains the two functions init
and post
.
The application is started on the javascript side with
my_app.init ({ data: <initialisation object>, element_id: <id of the element under which the application works>, onMessage: <function to receive messages on the javascript side from the application> })
The javascript code can post messages to the application by
my_app.post (message)
val application :
string ->
('state * 'msg Command.t) Decoder.t ->
('state -> 'msg Html.t * string) ->
('state -> 'msg Subscription.t) ->
('state -> 'msg -> 'state * 'msg Command.t) ->
unit
application my_app init view subs update
Create a browser application named my_app
on the javascript side. The application creates the global object named my_app
which contains the two functions init
and post
.
The application is started on the javascript side with
my_app.init ({ data: <initialisation object>, onMessage: <function to receive messages on the javascript side from the application> })
The javascript code can post messages to the application by
my_app.post (message)