lustre_hash_state

Functions

pub fn from_base64(value: String) -> String

A convenience method to base64 url decode individual values.

Example

lustre_hash_state.init(fn(key: String, value: String) {
  HashChange(key, value |> lustre_hash_state.from_base64)
})

will dipatch the HashChange msg with the decoded value.

pub fn get_hash() -> String

Returns the current window.location.hash value, including the octothorpe. It’s unlikely you’d call this directly, but public for convenience.

pub fn init(msg: fn(String, String) -> a) -> Effect(a)

The effect to be returned in your init method. Sets up hashchange event listener and sends messages to update.

Example

pub opaque type Msg {
  HashChange(key: String, value: String)
}

lustre_hash_state.init(HashChange)
// or
lustre_hash_state.init(fn(key: String, value: String) {
  HashChange(key, value)
})
pub fn noop() -> Effect(a)

A convenience method identical to effect.none()

pub fn parse_hash(query: String) -> Dict(String, String)

Parses a query string into a dict

pub fn stringify_hash(dct: Dict(String, String)) -> String

Converts a dict to a query string

pub fn to_base64(value: String) -> String

A convenience method to base64 url encode individual values.

Example

lustre_hash_state.update(key, value |> lustre_hash_state.to_base64)

will update the hash value as a base64 url encoded string.

pub fn update(key: String, value: String) -> Effect(a)

Updates the hash value.

Search Document