Module perseus::prelude

source ·
Expand description

A series of imports needed by most Perseus apps, in some form. This should be used in conjunction with the Sycamore prelude.

Re-exports

Macros

  • Logs the given format!-style data to the browser’s console, or to stdout on the server.

Structs

  • The options for constructing a Perseus app. This struct will tie together all your code, declaring to Perseus where your templates, error pages, static content, etc. are.

Traits

  • Trait that is implemented by all [GenericNode] backends that render to HTML.

Functions

  • The component that represents the entrypoint at which Perseus will inject itself. You can use this with the .index_view() method of PerseusAppBase to avoid having to create the entrypoint <div> manually.
  • Navigates to the specified url. The url should have the same origin as the app.
  • Navigates to the specified url without adding a new history entry. Instead, this replaces the current location with the new url. The url should have the same origin as the app.
  • Spawns a !Send future on the current scope. If the scope is destroyed before the future is completed, it is aborted immediately. This ensures that it is impossible to access any values referencing the scope after they are destroyed.

Type Definitions

Attribute Macros

  • A helper macro for templates that use reactive state. Once, this was needed on all Perseus templates, however, today, templates that take no state, or templates that take unreactive state, can be provided as normal functions to the methods .view() and .view_with_unreactive_state() respectively, on Perseus’ Template type.
  • Marks the given function as the browser entrypoint into your app. This is designed for more complex apps that need to manually distinguish between the engine and browser entrypoints.
  • A convenience macro that makes sure the given function is only defined on the browser-side, creating an empty function on the engine-side. Perseus implicitly expects your browser-side state modification functions to be defined in this way (though you certainly don’t have to use this macro).
  • Marks the given function as the engine entrypoint into your app. This is designed for more complex apps that need to manually distinguish between the engine and browser entrypoints.
  • A convenience macro that makes sure the given function is only defined on the engine-side, creating an empty function on the browser-side. Perseus implicitly expects most of your state generation functions to be defined in this way (though you certainly don’t have to use this macro).
  • Marks the given function as the universal entrypoint into your app. This is designed for simple use-cases, and the annotated function should return a PerseusApp. This will expand into separate main() functions for both the browser and engine sides.
  • This is identical to #[main], except it doesn’t require a server integration, because it sets your app up for exporting only. This is useful for apps not using server-requiring features (like incremental static generation and revalidation) that want to avoid bringing in another dependency on the server-side.
  • Marks the given function as a Perseus test. Functions marked with this attribute must have the following signature: async fn foo(client: &mut fantoccini::Client) -> Result<>.

Derive Macros

  • Processes the given struct to create a reactive version by wrapping each field in a Signal. This will generate a new struct with the given name and implement a .make_rx() method on the original that allows turning an instance of the unreactive struct into an instance of the reactive one.