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>}(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.
(cleanup-session! app-state* session-id)Remove session state and all associated tabs.
Remove session state and all associated tabs.
(cleanup-tab! app-state* tab-id)Remove tab state and unlink from session.
Remove tab state and unlink from session.
(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.
(get-or-create-session! app-state* session-id)Ensure session exists in app-state.
Ensure session exists in app-state.
(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.
(get-tab-route app-state* tab-id)Get the current route for a tab.
Get the current route for a tab.
(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.
(init-state)Create initial app state structure.
Create initial app state structure.
(normalize-path path)Convert keyword or vector to vector path.
Convert keyword or vector to vector path.
(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.
(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.
(set-tab-route! app-state* tab-id route-info)Set the current route for a tab.
Set the current route for a tab.
(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.
(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.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |