Callbacks define a standard way to store functions and closures. They are useful
for component properties, because they can be used to define optional callback functions,
which generic props don’t support.
This module contains the Oco (Owned Clones Once) smart pointer,
which is used to store immutable references to values.
This is useful for storing, for example, strings.
A single, global suspense context that will be checked when resources
are read. This won’t be “blocked” by lower suspense components. This is
useful for e.g., holding route transitions.
This struct serves as a convenient place to store details used for configuring Leptos.
It’s used in our actix, axum, and viz integrations to generate the
correct path for WASM, JS, and Websockets, as well as other configuration tasks.
It shares keys with cargo-leptos, to allow for easy interoperability
A wrapping type for an optional component prop, which can either be a signal or a
non-reactive value, and which may or may not have a value. In other words, this is
an Option<MaybeSignal<Option<T>>> that automatically flattens its getters.
A signal that combines the getter and setter into one value, rather than
separating them into a ReadSignal and a WriteSignal. You may prefer this
its style, or it may be easier to pass around in a context or as a function argument.
New-type wrapper for the a function that returns a view with From and Default traits implemented
to enable optional props in for example <Show> and <Suspense>.
Represents the different possible values a single class on an element could have,
allowing you to do fine-grained updates to single items
in Element.classList.
“Owned Clones Once” - a smart pointer that can be either a reference,
an owned value, or a reference counted pointer. This is useful for
storing immutable values, such as strings, in a way that is cheap to
clone and pass around.
Describes errors that can occur while serializing and deserializing data,
typically during the process of streaming Resources from
the server to the client.
Defines a “server function.” A server function can be called from the server or the client,
but the body of its code will only be run on the server, i.e., if a crate feature ssr is enabled.
Trait implemented for all signal types which you can get a value
from, such as ReadSignal,
Memo, etc., which allows getting the inner value without
subscribing to the current scope.
Trait implemented for all signal types which you can set the inner
value, such as WriteSignal and RwSignal, which allows setting
the inner value without causing effects which depend on the signal
from being run.
Defines a “server function.” A server function can be called from the server or the client,
but the body of its code will only be run on the server, i.e., if a crate feature ssr (server-side-rendering) is enabled.
A component that will show its children when the when condition is true.
Additionally, you need to specify a hide_delay. If the when condition changes to false,
the unmounting of the children will be delayed by the specified Duration.
If you provide the optional show_class and hide_class, you can create very easy mount /
unmount animations.
Allows you to inline the data loading for an async block or
server function directly into your view. This is the equivalent of combining a
create_resource that only loads once (i.e., with a source signal || ()) with
a Suspense with no fallback.
When you render a Result<_, _> in your view, in the Err case it will
render nothing, and search up through the view tree for an <ErrorBoundary/>.
This component lets you define a fallback that should be rendered in that
error case, allowing you to handle errors within a section of the interface.
A component that will show its children when the when condition is true,
and show the fallback when it is false, without rerendering every time
the condition changes.
If any Resource is read in the children of this
component, it will show the fallback while they are loading. Once all are resolved,
it will render the children.
If any Resources are read in the children of this
component, it will show the fallback while they are loading. Once all are resolved,
it will render the children. Unlike Suspense, this will not fall
back to the fallback state if there are further changes after the initial load.
Wraps the given function so that, whenever it is called, it creates
a child node owned by whichever reactive node was the owner
when it was created, runs the function, and returns a disposer that
can be used to dispose of the child later.
Batches any reactive updates, preventing effects from running until the whole
function has run. This allows you to prevent rerunning effects if multiple
signal updates might cause the same effect to run.
Creates a “blocking” Resource. When server-side rendering is used,
this resource will cause any <Suspense/> you read it under to block the initial
chunk of HTML from being sent to the client. This means that if you set things like
HTTP headers or <head> metadata in that <Suspense/>, that header material will
be included in the server’s original response.
Effects run a certain chunk of code whenever the signals they depend on change.
create_effect queues the given function to run once, tracks its dependence
on any signal values read within it, and reruns the function whenever the value
of a dependency changes.
Creates a localResource, which is a signal that
reflects the current state of an asynchronous task, allowing you to
integrate asyncFutures into the synchronous reactive system.
Creates an effect exactly like create_effect, but runs immediately rather
than being queued until the end of the current microtask. This is mostly used
inside the renderer but is available for use cases in which scheduling the effect
for the next tick is not optimal.
Creates a Resource, which is a signal that reflects the
current state of an asynchronous task, allowing you to integrate asyncFutures into the synchronous reactive system.
Creates a reactive signal with the getter and setter unified in one value.
You may prefer this style, or it may be easier to pass around in a context
or as a function argument.
Creates a conditional signal that only notifies subscribers when a change
in the source signal’s value changes whether it is equal to the key value
(as determined by PartialEq.)
Creates a signal that always contains the most recent value emitted by a
Stream.
If the stream has not yet emitted a value since the signal was created, the signal’s
value will be None.
Extracts a context value of type T from the reactive system by traversing
it upwards, beginning from the current reactive owner and iterating
through its parents, if any. The context value should have been provided elsewhere
using provide_context.
Loads LeptosOptions from a Cargo.toml with layered overrides. If an env var is specified, like LEPTOS_ENV,
it will override a setting in the file. It takes in an optional path to a Cargo.toml file. If None is provided,
you’ll need to set the options as environment variables or rely on the defaults. This is the preferred
approach for cargo-leptos. If Some(“./Cargo.toml”) is provided, Leptos will read in the settings itself. This
option currently does not allow dashes in file or folder names, as all dashes become underscores
The microtask is a short function which will run after the current task has
completed its work and when there is no other code waiting to be run before
control of the execution context is returned to the browser’s event loop.
Extracts a context value of type T from the reactive system by traversing
it upwards, beginning from the current reactive owner and iterating
through its parents, if any. The context value should have been provided elsewhere
using provide_context.
Defines a component as an interactive island when you are using the
experimental-islands feature of Leptos. Apart from the macro name,
the API is the same as the component macro.