Liking cljdoc? Tell your friends :D

hyper.state

State management for hyper applications.

Manages session and tab-scoped state using atoms and cursors. Cursors implement IRef for familiar Clojure semantics.

State structure: {:global {} :sessions {session-id {:data {} :tabs #{tab-id}}} :tabs {tab-id {:data {} :session-id session-id :render-fn fn :sse-channel ch :route {:name :home :path "/" :path-params {} :query-params {}}}} :actions {action-id {:fn fn :session-id sid :tab-id tid}} :router <reitit-router> :routes <original-routes-vector> :routes-source <var-or-routes-vector>}

State management for hyper applications.

Manages session and tab-scoped state using atoms and cursors.
Cursors implement IRef for familiar Clojure semantics.

State structure:
{:global {}
 :sessions {session-id {:data {} :tabs #{tab-id}}}
 :tabs {tab-id {:data {} :session-id session-id :render-fn fn :sse-channel ch
                :route {:name :home :path "/" :path-params {} :query-params {}}}}
 :actions {action-id {:fn fn :session-id sid :tab-id tid}}
 :router <reitit-router>
 :routes <original-routes-vector>
 :routes-source <var-or-routes-vector>}
raw docstring

build-urlclj

(build-url path query-params)

Build a URL string from a path and query params map. Omits query params with nil values. Returns path if no query params remain. Delegates to hyper.utils/build-url.

Build a URL string from a path and query params map.
Omits query params with nil values.
Returns path if no query params remain.
Delegates to hyper.utils/build-url.
sourceraw docstring

cleanup-session!clj

(cleanup-session! app-state* session-id)

Remove session state and all associated tabs.

Remove session state and all associated tabs.
sourceraw docstring

cleanup-tab!clj

(cleanup-tab! app-state* tab-id)

Remove tab state and unlink from session.

Remove tab state and unlink from session.
sourceraw docstring

create-cursorclj

(create-cursor parent-atom path-prefix path)

Create a cursor pointing to a path in the parent atom. path-prefix is the base path, path is relative to that.

Create a cursor pointing to a path in the parent atom.
path-prefix is the base path, path is relative to that.
sourceraw docstring

get-or-create-session!clj

(get-or-create-session! app-state* session-id)

Ensure session exists in app-state.

Ensure session exists in app-state.
sourceraw docstring

get-or-create-tab!clj

(get-or-create-tab! app-state* session-id tab-id)

Ensure tab exists in app-state and is linked to session.

Ensure tab exists in app-state and is linked to session.
sourceraw docstring

get-tab-routeclj

(get-tab-route app-state* tab-id)

Get the current route for a tab.

Get the current route for a tab.
sourceraw docstring

global-cursorclj

(global-cursor app-state* path)
(global-cursor app-state* path default-value)

Create a cursor to global state at the given path. Global state is shared across all sessions and tabs. If default-value is provided and the path is nil, initializes with default-value.

Create a cursor to global state at the given path.
Global state is shared across all sessions and tabs.
If default-value is provided and the path is nil, initializes with default-value.
sourceraw docstring

init-stateclj

(init-state)

Create initial app state structure.

Create initial app state structure.
sourceraw docstring

normalize-pathclj

(normalize-path path)

Convert keyword or vector to vector path.

Convert keyword or vector to vector path.
sourceraw docstring

parse-query-stringclj

(parse-query-string query-string)

Parse a query string into a keyword-keyed map with URL-decoded values. Returns nil if query-string is nil. Delegates to hyper.utils/parse-query-string.

Parse a query string into a keyword-keyed map with URL-decoded values.
Returns nil if query-string is nil.
Delegates to hyper.utils/parse-query-string.
sourceraw docstring

session-cursorclj

(session-cursor app-state* session-id path)
(session-cursor app-state* session-id path default-value)

Create a cursor to session state at the given path. If default-value is provided and the path is nil, initializes with default-value.

Create a cursor to session state at the given path.
If default-value is provided and the path is nil, initializes with default-value.
sourceraw docstring

set-tab-route!clj

(set-tab-route! app-state* tab-id route-info)

Set the current route for a tab.

Set the current route for a tab.
sourceraw docstring

stamp-scope!clj

(stamp-scope! cursor scope path)

Stamp a cursor with :hyper/scope and :hyper/path metadata. Returns the cursor.

Stamp a cursor with :hyper/scope and :hyper/path metadata.  Returns the
cursor.
sourceraw docstring

tab-cursorclj

(tab-cursor app-state* tab-id path)
(tab-cursor app-state* tab-id path default-value)

Create a cursor to tab state at the given path. If default-value is provided and the path is nil, initializes with default-value.

Create a cursor to tab state at the given path.
If default-value is provided and the path is nil, initializes with default-value.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close