v0.7.0-preview2
版本发布时间: 2024-04-29 09:13:52
leptos-rs/leptos最新发布版本:v0.7.0-rc0(2024-10-22 09:30:46)
The -preview
here is intended to convey: Here is a mostly-working but pre-alpha release of what I've been working on for the last six months or so. This work can be found in the leptos-0.7
branch. Enough work has been done that many (but not all) of the examples in the repo are functioning. This release is a fairly complete rewrite of the internals of the entire framework. You should expect both missing APIs and bugs.
Note the following:
- You probably cannot just drop
0.7.0-preview2
to theCargo.toml
of an existing app and expect it to work - Imports have moved around a bit, to help improve discoverability, including moving from
use leptos::*;
touse leptos::prelude::*;
and then using modules and reexports more sanely from the main crate - I've created a
0.7.0-preview
playground that includes the setup of a basic app with comments. You should be able to expand from there. - There are lots of missing docs. These are easier to fill in going forward than to keep up to date during really active development.
Examples that Work
The following examples in the repo are known to work and can be useful to learn from
-
counter
-
counters
-
error_boundary
-
fetch
-
todomvc
-
parent_child
-
router
-
todo_app_sqlite_axum
-
ssr_modes_axum
Notable Changes
- I'm trying to avoid using features to change behavior as much as possible; see examples for
Cargo.toml
setup -
use leptos::prelude::*
instead ofuse leptos::*
- Reactive system is now
Send
/Sync
. In general for values being stored in signals this means you need to useArc
on occasion instead ofRc
, etc.- For browser-only types stored inside signals I've tended to use the
send_wrapper
crate. Better ergonomics here are an open question
- For browser-only types stored inside signals I've tended to use the
- The renderer and
IntoView
trait work quite differently from before. In general, for type-erased views (.into_view()
previously) you can use.into_any()
or theEither::
types. Storing aView
in a signal, cloning it, etc. are not viable approaches any more: store data in signals and rendering views, rather than storing views in signals. - There are
Arc
equivalents to each signal type (ArcRwSignal
,ArcMemo
, etc.) which manage their lifecycle via reference counting rather than the reactive ownership graph. This can be used for things like iterating over nested signals (seecounters
example) and pushing signals "up" in the tree, rather than using the manual.dispose()
and owner manipulation patterns - Continuing to move names toward more typical Rust naming patterns (
RwSignal::new()
,signal()
instead ofcreate_signal()
to matchchannel()
, etc.) - Suspense now uses actual async -- see examples
- The router uses a more statically-typed/compile-time route segment matching pattern. I have plans for a
path!()
macro to parse the old strings into this format but it's not implemented. - Route matching is now "first match wins," rather than using a scoring algorithm. I think this should work similarly to server-side route matching, but is not exactly how the old system worked.
Known Missing APIs
- Actix integration (the playground uses Axum)
-
on:
on components -
MaybeSignal
-
Signal::with()
- spreading attributes onto components
-
cargo-leptos
hot reloading - anything animated (AnimatedShow, AnimatedRoutes, AnimatedOutlet)
- Portals
- slots
- islands?
- ... will add more here
Steps before -alpha
- Migrate remaining examples
- Missing features (above)
- Update docs
- Update tests
What's Helpful?
Try things out, see what breaks, see what feels good. How can we improve the module imports? What are pain points? etc. Feel free to comment here or on Discord in the #preview
channel,