package jsoo_storage

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module WebStorage.LocalSource

Support for LocalStorage

Sourcetype key = string
Sourcetype value = string
Sourcetype old_value = string
Sourcetype url = string
Sourcetype change_state =
  1. | Clear
  2. | Insert of key * value
  3. | Remove of key * old_value
  4. | Update of key * old_value * value

This type represents a changeset on the storage

Sourceval dump_change_state : change_state -> string

Dump a changestate (mainly for debugging)

Sourceval is_supported : unit -> bool

is_supported () returns true if the current storage is supported by the browser, false otherwise.

Sourceval handler : t

Returns the JavaScript's representation of the storage object

Sourceval length : unit -> int

The length read-only property of the Storage interface returns an integer representing the number of data items stored in the Storage object.

Sourceval get : key -> value option

When passed a key name, will return that key's value. (Wrapped into an option)

Sourceval set : key -> value -> unit

When passed a key name and value, will add that key to the storage, or update that key's value if it already exists.)

Sourceval remove : key -> unit

When passed a key name, will remove that key from the storage.

Sourceval clear : unit -> unit

When invoked, clears all stored keys.

Sourceval 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.

Sourceval at : int -> (key * value) option

Returns the couple Key/Value at a specific position

Sourceval to_hashtbl : unit -> (key, value) Hashtbl.t

Produce an Hashtbl.t from a Storage

Sourceval iter : (key -> value -> unit) -> unit

applies function f on each key/value of a storage

Sourceval find : (key -> value -> bool) -> (key * value) option

find p returns the first element of the storage that satisfies the predicate p. The result is wrapped into an option.

Sourceval select : (key -> value -> bool) -> (key, value) Hashtbl.t

select p returns all the elements of the storage that satisfy the predicate p. The results is an Hashtbl.t of the results.

Sourceval 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))

Sourceval on_clear : (url -> unit) -> Js_of_ocaml.Dom.event_listener_id

on_clear f trigger f at each clear of the storage.

Sourceval 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))

Sourceval 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))

Sourceval 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))

OCaml

Innovation. Community. Security.