Module States

module States: sig .. end
Synchronized values between Server and Client

type 'a callback = ('a -> unit) -> unit 
val register_value : page:Doc.page ->
name:string ->
descr:Markdown.text ->
?details:Markdown.block ->
output:'a Request.output ->
get:(unit -> 'a) -> ?add_hook:unit callback -> unit -> Request.signal
Register a (projectified) value and generates the associated signal and request: If provided, the ~add_hook option is used to register a hook to notify the server of value updates. The hook will be installed only once the client starts to listen for value updates.

Inside Ivette you can use the States.useSyncValue(id) hook to synchronize with this value.

val register_state : page:Doc.page ->
name:string ->
descr:Markdown.text ->
?details:Markdown.block ->
data:'a Data.data ->
get:(unit -> 'a) ->
set:('a -> unit) -> ?add_hook:unit callback -> unit -> Request.signal
Register a (projectified) state and generates the associated signal and requests: If provided, the ~add_hook option is used to register a hook to notify the server of value updates. The hook will be installed only once the client starts to listen for value updates.

Inside Ivette you can use the States.useSyncState(id) hook to synchronize with this state.

type 'a model 
Columns array model
val model : unit -> 'a model
Creates an empty array model.
val column : model:'a model ->
name:string ->
descr:Markdown.text ->
data:'b Request.output -> get:('a -> 'b) -> unit -> unit
Populate an array model with a new field. Columns with name `"id"` and `"_index"` are reserved for internal use.
type 'a array 
Synchronized array state.
val reload : 'a array -> unit
Mark the array to be fully reloaded.
val update : 'a array -> 'a -> unit
Mark an array entry as updated.
val remove : 'a array -> 'a -> unit
Mark an array entry as removed.
val signal : 'a array -> Request.signal
Get the signal associated with the array.
val register_array : page:Doc.page ->
name:string ->
descr:Markdown.text ->
?details:Markdown.block ->
key:('a -> string) ->
iter:'a callback ->
?add_update_hook:'a callback ->
?add_remove_hook:'a callback ->
?add_reload_hook:unit callback -> 'a model -> 'a array
Register everything necessary to synchronize an array with the client: The ~key parameter is used to identify array entries, and used to fill the reserved column "id" of entries.

Columns added to the model after registration are not taken into account.

If provided, the ~add_xxx_hook options are used to register hooks to notify the server of corresponding array updates. Each hook will be installed only once the client starts to listen for array updates.

Inside Ivette you can obtain the entries in sync by using the States.useSyncArray() hook.