Fmlib_browserSourceWeb Applications Running in the Browser
Introduction to Web Applications
Event flags to stop propagation and prevent default action.
Subscriptions to global events.
val element :
string ->
('state * 'msg Command.t) Decoder.t ->
('state -> 'msg Html.t) ->
('state -> 'msg Subscription.t) ->
('state -> 'msg -> 'state * 'msg Command.t) ->
unitelement 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) ->
unitapplication 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)