Module Brr.History

module History: sig .. end
Browser history.

TODO. Needs redesign/review.

Moving in history

val length : unit -> int
length () is the number of elements in the history including the currently loaded page.
val go : int -> unit
go step goes step numbers forward (positive) or backward (negative) in history.
val back : unit -> unit
back () is go ~-1.
val forward : unit -> unit
forward () is go 1.

History state

Warning. History state is unsafe if you don't properly version you state. Any change in state representation should entail a new version.

type 'a state 
The type for state.
val create_state : version:Brr.Jstr.t -> 'a -> 'a state
create_state version v is state v with version version.
val state : version:Brr.Jstr.t -> default:'a -> unit -> 'a
state version deafult () is the current state if it matches version. If it doesn't match or there is no state default is returned.

Making history

val push : ?replace:bool ->
?state:'a state -> title:Brr.Jstr.t -> Brr.Jstr.t -> unit
push ~replace ~state ~title uri changes the browser location to uri but doesn't load the URI. title is a human title for the location to which we are moving and state is a possible value associated to the location. If replace is true (defaults to false) the current location is replaced rather than added to history.