module Make_Simple : functor (A : ARG_SIMPLE) ->
with type key = A.key
and type server_notif = A.notification
and type client_notif = A.notification
Use this functor if you have no need of customising your notifications with client-specific data.
identity is the type of values used to differentiate one listener from another. Typically it will be a user, but it could also for instance be a chat window.
key is the type of values designating a given resource.
server notification type; Can be different from client_notif.
client notification type; Can be different from server_notif.
val init : unit -> unit Lwt.t
Initialise the notification module for the current client. This function needs to be called before using most other functions of this module. It isn't called implicitely during module instantiation because it relies on identity data which might not be available yet.
val deinit : unit -> unit
Deinitialise/deactivate the notification module for the current client.
val listen : key -> unit
Make client process listen on data whose index is key
val unlisten : key -> unit
Stop listening on data key
val notify :
?notfor:[ `Id of identity | `Me ] ->
key -> server_notif -> unit
Call notify key n to send a notification n to all clients currently listening on data referenced by key.
If ~notfor is `Me, notification will not be sent to the tab currently doing the request (the one which caused the notification to happen). Note that if notify is called with ~notfor:`Me outside of a request it will fail. If it is `Id id it won't be sent to the destination defined by id.
val client_ev :
(key * client_notif) Eliom_react.Down.t
Returns the client react event. Map a function on this event to react to notifications from the server. For example:
let%client handle_notification some_stuff ev = ...
let%server something some_stuff = ignore %client (ignore (React.E.map (handle_notification ~%some_stuff) ~%(Notif_module.client_ev ()) ) : unit)
val clean : unit -> unit
Call clean () to clear the tables from empty data.