Expand description

Utilities for working with Perseus’ state platform.

Structs

A representation of a frozen app.

A representation of the global state in an app.

A creator for global state. This stores user-provided functions that will be invoked to generate global state on the client and the server.

A frozen state store that uses IndexedDB as a backend. This will only store a single frozen state at a time, removing all previously stored states every time a new one is set.

A container for page state in Perseus. This is designed as a context store, in which one of each type can be stored. Therefore, it acts very similarly to Sycamore’s context system, though it’s specifically designed for each page to store one reactive properties object. In theory, you could interact with this entirely independently of Perseus’ state interface, though this isn’t recommended.

The user’s preferences on state thawing.

Enums

The user’s preferences on page state thawing. Templates have three places they can fetch state from: the page state store (called active state), the frozen state, and the server. They’re typically prioritized in that order, but if thawing occurs later in an app, it may be desirable to override active state in favor of frozen state. These preferences allow setting an inclusion or exclusion list.

Traits

A convenience super-trait for Freezeable things that can be downcast to concrete types.

A trait for reactive structs that can be made unreactive and serialized to a String. structs that implement this should implement MakeUnrx for simplicity, but they technically don’t have to (they always do in Perseus macro-generated code).

A trait for structs that can be made reactive. Typically, this will be derived with the #[make_rx] macro, though it can be implemented manually if you have more niche requirements.

A trait for reactive structs that can be made un-reactive. This is the opposite of MakeRx, and is intended particularly for state freezing. Like MakeRx, this will usually be derived automatically with the #[make_rx] macro, but you can also implement it manually.

Functions

Force-reloads the page. Any code after this will NOT be called, as the browser will completely reload the page, dumping your code and restarting from the beginning. This will result in a total loss of all state unless it’s frozen in some way.

Freezes the app’s state to IndexedDB to be accessed in future.

Thaws a previous state frozen in development.