jsoo_storage
Library
Module
Module type
Parameter
Class
Class type
type change_state =
| Clear |
| Insert of key * value |
| Remove of key * old_value |
| Update of key * old_value * value |
This type represents a changeset on the storage
val dump_change_state : change_state -> string
Dump a changestate (mainly for debugging)
is_supported ()
returns true
if the current storage is supported by the browser, false otherwise.
val handler : t
Returns the JavaScript's representation of the storage object
The length read-only property of the Storage interface returns an integer representing the number of data items stored in the Storage object.
When passed a key name, will return that key's value. (Wrapped into an option)
When passed a key name and value, will add that key to the storage, or update that key's value if it already exists.)
val remove : key -> unit
When passed a key name, will remove that key from the storage.
val key : int -> key option
When passed a number n, returns the name of the nth key in the storage. The order of keys is user-agent
defined, so you should not rely on it.
find p
returns the first element of the storage that satisfies the predicate p
. The result is wrapped into an option.
select p
returns all the elements of the storage that satisfy the predicate p
. The results is an Hashtbl.t
of the results.
val on_change :
?prefix:string ->
( change_state -> url -> unit ) ->
Js_of_ocaml.Dom.event_listener_id
on_change f
trigger f
at each changement of the storage. (You can use a prefix
to trigger the events only if it concerns a set of keys (with the gived prefix))
val on_clear : ( url -> unit ) -> Js_of_ocaml.Dom.event_listener_id
on_clear f
trigger f
at each clear of the storage.
val on_insert :
?prefix:string ->
( key -> value -> url -> unit ) ->
Js_of_ocaml.Dom.event_listener_id
on_insert f
trigger f
at each insertion in the storage. (You can use a prefix
to trigger the events only if it concerns a set of keys (with the gived prefix))
val on_remove :
?prefix:string ->
( key -> old_value -> url -> unit ) ->
Js_of_ocaml.Dom.event_listener_id
on_remove f
trigger f
at each remove in the storage. (You can use a prefix
to trigger the events only if it concerns a set of keys (with the gived prefix))
val on_update :
?prefix:string ->
( key -> old_value -> value -> url -> unit ) ->
Js_of_ocaml.Dom.event_listener_id
on_update f
trigger f
at each key update in the storage. (You can use a prefix
to trigger the events only if it concerns a set of keys (with the gived prefix))