package bonsai
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
A library for building dynamic webapps, using Js_of_ocaml
Install
dune-project
Dependency
Authors
Maintainers
Sources
v0.17.0.tar.gz
sha256=c78c4476ee6b856846e2d0941e5965009d5e1b853e564b2b1bee61202f0b1ebb
doc/bonsai.web/Bonsai_web/Persistent_var/index.html
Module Bonsai_web.Persistent_varSource
Source
val create :
(module Core.Sexpable with type t = 'a) ->
[ `Local_storage | `Session_storage ] ->
unique_id:string ->
default:'a ->
'a tA Persistent_var.t is similar to Bonsai.Var.t, but the contents of the var are persisted into either local storage or session storage.
Creating a persistent var requires that the type contained inside the var to be sexpable, so a first class module for the type should be passed in.
You have a choice between Local Storage and Session Storage for actually persisting things; The docs for which can be found here:
- https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
- https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
A unique_id is required for the storage. This value needs to be unique per application.
Finally, a fallback is required for when the value can't be found, or it can't be deserialized.
This will remove the value from localstorage or sessionstorage. (calling set or update afterwards will still store the value back again.)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>