package bonsai

  1. Overview
  2. Docs
A library for building dynamic webapps, using Js_of_ocaml

Install

Dune Dependency

Authors

Maintainers

Sources

bonsai-v0.16.0.tar.gz
sha256=1d68aab713659951eba5b85f21d6f9382e0efa8579a02c3be65d9071c6e86303

doc/bonsai.web_ui_url_var/Bonsai_web_ui_url_var/index.html

Module Bonsai_web_ui_url_varSource

Sourcemodule Components : sig ... end
module Original_components := Components
Sourcemodule type T = sig ... end
Sourcemodule type S = sig ... end

Types that implement S can be parsed from a url and unparsed into a url.

Sourcemodule type S_via_sexp = sig ... end

Types that are sexpable can be turned a URL by storing the value as a sexp in a query parameter.

Sourcetype 'a t
Sourceval create_exn : (module S with type t = 'a) -> fallback:'a -> 'a t

Creating a url-var involves passing in a module that implements S, but also a fallback value which will be used if S.parse_exn throws.

Sourceval set : ?how:[ `Push | `Replace ] -> 'a t -> 'a -> unit

set updates the contents of the url-var as well as the current browser location. When how is `Push (which is the default), it will add a new entry to the top of the browser's history stack, but `Replace will cause it to replace the top entry of the history stack with the new URL.

Sourceval update : ?how:[ `Push | `Replace ] -> 'a t -> f:('a -> 'a) -> unit

update is like set, but gives you access to the previous value of the url right before setting it.

Sourceval update_effect : ?how:[ `Push | `Replace ] -> 'a t -> f:('a -> 'a) -> unit Bonsai_web.Effect.t
Sourceval get : 'a t -> 'a
Sourceval value : 'a t -> 'a Bonsai_web.Value.t
Sourceval incr : 'a t -> 'a Ui_incr.t
Sourceval set_effect : ?how:[ `Push | `Replace ] -> 'a t -> 'a -> unit Bonsai_web.Effect.t

By asking for the Url_var.t's effect, you get a function that can be easily threaded through your components and triggered inside an action-application or inside of an event listener.

Sourcetype 'a url_var = 'a t
Sourcemodule Typed : sig ... end

This module allows you to define your Url_var out of an OCaml type similar to the Typed Forms API. The module provides nice features like static analysis of your parser, ambiguity checking and functions to make backwards compatibility easier. Please read ../README.mdx first to make reading this MLI easier.

Sourcemodule For_testing : sig ... end
OCaml

Innovation. Community. Security.