Repository navigation
fix(deps): update rust crate leptos_router to v0.5.2 - #34
Closed
renovate[bot] wants to merge 1 commit into
Closed
renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
renovate
Bot
force-pushed
the
renovate/leptos_router-0.x
branch
from
August 2, 2023 22:39
9233d34 to
e712c7c
Compare
renovate
Bot
force-pushed
the
renovate/leptos_router-0.x
branch
from
August 3, 2023 00:48
e712c7c to
5cf245b
Compare
renovate
Bot
force-pushed
the
renovate/leptos_router-0.x
branch
from
August 20, 2023 22:45
5cf245b to
de7ea7c
Compare
renovate
Bot
force-pushed
the
renovate/leptos_router-0.x
branch
from
August 23, 2023 17:47
de7ea7c to
a8549c1
Compare
renovate
Bot
force-pushed
the
renovate/leptos_router-0.x
branch
from
September 29, 2023 22:08
a8549c1 to
eccb3fa
Compare
renovate
Bot
force-pushed
the
renovate/leptos_router-0.x
branch
from
October 6, 2023 15:48
eccb3fa to
c16c990
Compare
renovate
Bot
force-pushed
the
renovate/leptos_router-0.x
branch
from
October 25, 2023 01:48
c16c990 to
5d25532
Compare
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.4.5->0.5.20.4->0.5Release Notes
leptos-rs/leptos (leptos_router)
v0.5.2Compare Source
This has a bunch of bugfixes, small docs improvements, etc. but there are actually a bunch of cool new features, mostly from our growing body of contributors. See the full changelog below, but here are some highlights (apologies if I missed anything big)
Features
extractor()function with better APIThe
extractAPI is awkward due to closure. This adds anextractorfunction which is a little more ergonomic.<Portal/>Adds a portal component that lets you render some view mounted in a location other than where it appears in the view tree.
Server Function Named Arguments
Now that we've made all server function arguments optional, this adds in the ability to pass in one or more named arguments:
Directives
Adds support for directive functions, which can be used with
use:in the view:slice!()macroMakes it easier to define slices. Expands to the same output as
create_slice:What's Changed
leptos_reactive::Triggerby @hiraginoyuki in https://github.com/leptos-rs/leptos/pull/1844extractorfunctions with better API thanextractby @gbj in https://github.com/leptos-rs/leptos/pull/1859.try_with_untracked(closes #1880) by @gbj in https://github.com/leptos-rs/leptos/pull/1881#[must_use]to avoid accidental()rendering by @gbj in https://github.com/leptos-rs/leptos/pull/1885cargo make lintforhackernews_js_fetchby @gbj in https://github.com/leptos-rs/leptos/pull/1887ActionFormin an island by @gbj in https://github.com/leptos-rs/leptos/pull/1888on_cleanup(closes #1882) by @gbj in https://github.com/leptos-rs/leptos/pull/1889/in splat routes (closes #1764) by @gbj in https://github.com/leptos-rs/leptos/pull/1890newmethod toNodeRefby @tqwewe in https://github.com/leptos-rs/leptos/pull/1896Clonerequirement onSignalWithforResourceby @Xendergo in https://github.com/leptos-rs/leptos/pull/1895/in more routes by @PianoPrinter in https://github.com/leptos-rs/leptos/pull/1900try_update()andtry_set()onResourceshould not panic (closes #1915) by @gbj in https://github.com/leptos-rs/leptos/pull/1916defaultandwasmfeatures onleptos_axum(closes #1872) by @gbj in https://github.com/leptos-rs/leptos/pull/1883replaceproperty to form component by @koopa1338 in https://github.com/leptos-rs/leptos/pull/1923create_slice()by @SadraMoh in https://github.com/leptos-rs/leptos/pull/1867wee_allocto make Dependabot happy by @gbj in https://github.com/leptos-rs/leptos/pull/1938</head>tags in streaming responses (closes #1930) by @gbj in https://github.com/leptos-rs/leptos/pull/1932New Contributors
Full Changelog: leptos-rs/leptos@v0.5.1...v0.5.2
v0.5.1Compare Source
This is primarily a bugfix release, but it also includes a new feature: making the
fallbackprop onShow,Suspense, andTransitionoptional.For 0.5 release notes in general, click here.
What's Changed
Forview prop name (closes #1813) by @gbj in https://github.com/leptos-rs/leptos/pull/1814Copyimpl forCallbackby @gbj in https://github.com/leptos-rs/leptos/pull/1818intellij-rustby @sebadob in https://github.com/leptos-rs/leptos/pull/1804{..attrs}syntax (fixes #1826) by @gbj in https://github.com/leptos-rs/leptos/pull/1831with!andupdate!by @blorbb in https://github.com/leptos-rs/leptos/pull/1836generate_route_listif you immediately dispatch an action (closes #1832) by @gbj in https://github.com/leptos-rs/leptos/pull/1853clippy"needless lifetimes" warning (closes #1825) by @gbj in https://github.com/leptos-rs/leptos/pull/1852New Contributors
Full Changelog: leptos-rs/leptos@v0.5.0...v0.5.1
v0.5.0v0.5.0Goodbye,
ScopeThis long-awaited release changes the nature of the reactive system by removing the entire concept of explicit
Scopeand the ubiquitouscxvariable.The primary impetus behind this change is that it increases the correctness of the behavior of the reactive system, and fixes several persistent issues.
Click here for more details.
In order to provide signals that implement `Copy` are are `'static` and are therefore easy to use with closures and event listeners in 100% safe Rust, Leptos allocates memory for signals, memos, and effects in an arena. This raises the question: When is it safe to deallocate/dispose of these signals?From 0.0 to 0.4, Leptos allocated signals in a dedicated
Scope, which was ubiquitous in APIs. This had several drawbacksScopeargument on many functions prevented us from implementing many traits that could not take an additional argument on signals, likeFrom,Serialize/Deserialize.Scopewas stored in a variable that was passed around, meaning that the “wrong” scope could be passed into functions (most frequentlyResource::read()). If, for example, a derived signal or memo read from a resource in the component body, and was called under aSuspenselower in the tree, theScopeused would be from the parent component, not theSuspense. This was just wrong, but involved wrapping the function in another closure to pass in the correctScope.Scopes were manually created and disposed, or in whichon_cleanupwas never called. (See #802 and #918 for more background.)The solution to this problem was to do what I should have been doing a year ago, and merge the memory allocation function of
Scopeinto the reactive graph itself, which already handles reactive unsubscriptions and cleanup. JavaScript doesn’t deal with memory management, but SolidJS handles itsonCleanupthrough a concept of reactive ownership; disposing of memory for our signals is really just a case of cleanup on an effect or memo rerunning.Essentially, rather than being owned by a
Scopeevery signal, effect, or memo is now owned by its parent effect or memo. (If it’s in anuntrack, there’s no reactive observer but the reactive owner remains.) Every time an effect or memo reruns, it disposes of everything “beneath” it in the tree. This makes sense: for a signal to be owned by an effect/memo, it must have been created during the previous run, and will be recreated as needed during the next run, so this is the perfect time to dispose of it.It also has the fairly large benefit of removing the need to pass
cxorScopevariables around at all, and allowing the implementation of a bunch of different traits on the various signal types.Now that we don't need an extra
Scopeargument to construct them, many of the signal types now implementSerialize/Deserializedirectly, as well asFrom<T>. This should make it significantly easier to do things like "reactively serialize a nested data structure in acreate_effect" — this removed literally dozens of lines of serialization/deserialization logic and a custom DTO from thetodomvcexample. Serializing a signal simply serializes its value, in a reactive way; deserializing into a signal creates a new signal containing that deserialized value.Migration is fairly easy. 95% of apps will migrate completely by making the following string replacements:
cx: Scope,=> (empty string)cx: Scope=> (empty string)cx,=> (empty string)(cx)=>()|cx|=>||Scope,=> (empty string)Scope=> (empty string) as needed|_, _|that become|_|or|_|that become||, particularly for thefallbackprops on<Show/>and<ErrorBoundary/>.Basically, there is no longer a
Scopetype, and anything that used to take it can simply be deleted.For the 5%: if you were doing tricky things like storing a
Scopesomewhere in a struct or variable and then reusing it, you should be able to achieve the same result by storingOwner::current()somewhere and then later using it inwith_owner(owner, move || { /* ... */ }). If you have issues with this kind of migration, please let me know by opening an issue or discussion thread and we can work through the migration.Islands
This release contains an initial, but very functional, implementation of the “islands architecture” for Leptos.
This adds an
experimental-islandsfeature that opts you into a rendering mode that's different from the traditional server-rendered/client-hydrated model described here, in which the entire page requested is rendered to HTML on the server for the first request, and then runs on the client to hydrate this server-rendered HTML, and subsequent navigations take place by rendering pages in the browser.With this islands feature on, components are only rendered on the server, by default. Navigations follow the traditional/multi-page-app (MPA) style of navigating by fetching a new HTML page from the server. The name "islands" comes from the concept of the "islands architecture," in which you opt into small “islands” of interactivity in an “ocean” of server-rendered, non-interactive HTML.
This allows reducing the WASM binary size by a lot (say ~80% for a typical demo app), making the time-to-interactive for a page load much faster. It also allows you to treat most components as “server components” and use server-only APIs, because those plain components will never need to be rendered in the browser.
I still need to write some guide-style docs for the book, but I tried to put a pretty good amount of information in the PR, which you should read if you’re interested in this topic or in trying out islands.
There’s significant additional exploration that will take place in this direction. Expect a longer treatment in an upcoming updated roadmap posted as a pinned issue.
Additional Reading
Static Site Generation
This release includes some preliminary work on building static site rendering directly into the framework, mostly as part of
leptos_routerand the server integrations. Static site generation is built off of two key components, a new<StaticRoute />component and theleptos_router::build_static_routesfunction.StaticRoutedefines a new static route. In order to be a static route, all parent routes must be static in order to ensure that complete URLs can be built as static pages. A “static route” means that a page can be rendered as a complete HTML page that is then cached and served on subsequent requests, rather than dynamically rendered, significantly reducing the server’s workload per request.StaticRoutetakes a path and view (like anyRoute) and astatic_paramsprop. This is a function that returns aFuture, which is used to provide a map of all the possible values for each route param. These static params are generated on the server. This means you can do something like call a#[server]function or access a database or the server filesystem. For example, if you have a/post/:idpath, you might query the database for a list of all blog posts and use that to generate a set of possible params.StaticRoutecan be given an optional mode:StaticMode::Upfront(the default) orStaticMode::Incremental.Upfrontmeans that all given routes will be generated when you callbuild_static_routes, and a 404 will be returned for any other pages.Incrementalmeans that all the options you give instatic_paramswill be generated up front, and additional pages will be generated when first requested and then cached.Where our routes are defined, we can include a
StaticRoute:In
main.rs, we build the static routes for the site on server startup:More to Come
There is additional work needed here as far as providing examples, and building out the story for things like invalidation (when to rebuild a page) and build hooks (when to build additional pages).
Other New Features in 0.5
attr:on components, and spreading attributesMakes it much easier to pass some set of attributes to be given to a component (with
attr:passed into a#[prop(attrs)]prop), and then to spread them onto an element with{..attrs}syntax.Generics on components in view
Newly added support for syntax that identifies a generic type for a component in the
viewCallbacktypesThis release includes a
Callbacktype that makes it much easier to pass optional callbacks as component props, which was previously not possible with generically-typed callbacks.with!()andupdate!()macrosNested
.with()calls are a pain. Now you can doinstead of
Rustier interfaces for signal types
This framework's origins as a Rust port of SolidJS mean we've inherited some functional-JS-isms. Combined with the need to pass
cxeverywhere prior to 0.5 this has tended to mean we've gone withcreate_and so on rather than Rusty::new(). This simply adds a few Rustier constructors likeOptional
#[server]ArgumentsAll arguments to
#[server]are now optional: change default prefix to/apiand default to generating aPascalCasetype name from the function nameJS Fetch API integration support
We have adapted the Axum integration to be usable when running inside JS-hosted WASM environments (Deno Deploy, Cloudflare Workers, etc.) This can be done by disabling
default-featuresonaxumandleptos_axum, using theaxum-js-fetchlibrary, and enabling thewasmfeature onleptos_axum.There's a full Hackernews example in the repo that runs within Deno.
Feature Grab-Bag
ResourceAPIs. Resources now follow the same API as other signals:.get()and.with()apply to the current value (which may beNone). This means the old.with(), which was only called when the resource had resolved, is now.map(). There's also a new.and_then()method which can be called to deeply map over resources that returnResult, like server functions. The goal of these methods is to reduce the amount of boilerplate mapping necessary with resources previously. Check out theResourcedocs for more info.create_effectnow returns anEffectstruct. This exists mostly so you can.dispose()it early if you need. (This may require adding some missing semicolons, ascreate_effectno longer returns().)create_effect’s first run is now scheduled on the next tick, usingqueueMicrotask. In other words,create_effectruns after your component returns a view, not immediately as the component runs. This removes most of the cases in which nestingrequest_animation_frameinside acreate_effecthad been necessary.impl Into<Cow<'static, str>>now takeimpl Into<Oco<'static, str>>.Oco(Owned Clones Once) is a new type designed to minimized the cost of cloning immutable string types, like the ones used in theView. Essentially this makes it cheaper to clone text nodes and attribute nodes within the renderer, without imposing an additional cost when you don't need to. This shouldn't require changes to your application in most cases of normal usage. (See #1480 for additional discussion.)Minor Breaking Changes
leptos_axum::generate_route_list()This function is no longer
async. This means removing a single.awaitfrommain.rsin any Leptos-Axum app, but brings the API of the Axum (and Viz) integrations into line with the Actix one, and unlocks the use of this function in some non-async settings where it was desired.<For/>propviewrenamedchildrenThe name of the function that renders each row of data to a view is now
childrenrather thanview. This means that the view can now be included inline, without needing to break out of the markup into another closure andview!macro invocation.In other words,
is the same as
which replaces
use_navigatenavigate function no longer returns a valueThe
navigate("path", options)call now usesrequest_animation_frameinternally to delay a tick before navigating, which solves a few odd edge cases having to do with redirecting immediately and the timing of reactive system cleanups. This was a change that arose during 0.3 and 0.4 and is being made now to coincide with other breaking changes and a new version.If you were relying on the
Result<_, _>here and want access to it, let me know and we can bring back a version that has it. Otherwise, this shouldn't really require any changes to your app.window_event_listenerand friends now return a handle for removalThis one was just an API oversight originally, again taking advantage of the semver update.
window_event_listenerand its untyped version now return aWindowListenerHandlewith a.remove()method that can be called explicitly to remove that event, for example in anon_cleanup.Other Breaking Changes
use_contextno longer works inside event listeners, insidespawn_local, etc. Useuse_contextinside the body of a component and move the context data into those other closures. (See here for more details.)bind:has been renamedlet:, which makes more sense for variable binding. (This applies to components likeAwaitand nowFor, which take arguments in theirchildren.)Transition’sset_pendingprop now applies#[prop(into)], which means it can take any signal setter. If you were doing something already likeset_pending=something.into()the compiler will now get confused; just remove that.into().create_effect’s first run is now scheduled on the next tick, usingqueueMicrotask. In other words,create_effectruns after your component returns a view, not immediately as the component runs. (Listing this as both a feature and a breaking change, as it is a behavior change!)log!,warn!, anderror!macros have been moved into a separateloggingmodule to avoid naming conflicts with thelogandtracingcrates. You can import them asuse leptos::logging::*;if desired.Valuetype rather than a generic (see #1578)ResourceAPIs: the function formerly known as.with()is now.map(), and.read()is now.get()to match other signals.What's Changed
Scope-based ownership to reactive ownership by @gbj in https://github.com/leptos-rs/leptos/pull/918.refetch()(occurs in e.g., async blocks in actions) by @gbj in https://github.com/leptos-rs/leptos/pull/1576render_to_string_asyncby @gbj in https://github.com/leptos-rs/leptos/pull/1574Fntraits for resources on nightly by @gbj in https://github.com/leptos-rs/leptos/pull/1587typed-builder0.16 (closes #1455) by @gbj in https://github.com/leptos-rs/leptos/pull/1590Oco(Owned Clones Once) smart pointer by @DanikVitek in https://github.com/leptos-rs/leptos/pull/1480get_propertyby @jquesada2016 in https://github.com/leptos-rs/leptos/pull/1638loggingmodule to avoid name conflicts withlogandtracingby @gbj in https://github.com/leptos-rs/leptos/pull/1658RcbackedChildrenFnby @Baptistemontan in https://github.com/leptos-rs/leptos/pull/1669extract_with_statefunction by @gbj in https://github.com/leptos-rs/leptos/pull/1683mount_to_bodyin CSR mode by @gbj in https://github.com/leptos-rs/leptos/pull/1688#[island]macro by @gbj in https://github.com/leptos-rs/leptos/pull/1691IntoViewforRc<dyn Fn() -> impl IntoView>by @Baptistemontan in https://github.com/leptos-rs/leptos/pull/1698From<HtmlElement<El>> for HtmlElement<AnyElement>by @jquesada2016 in https://github.com/leptos-rs/leptos/pull/1700componentmacro by @ChristopherPerry6060 in https://github.com/leptos-rs/leptos/pull/1696moveonwith!macros by @blorbb in https://github.com/leptos-rs/leptos/pull/1717SerializeandDeserializeforOco<_>by @gbj in [https://github.com/feat: implementSerializeandDeserializeforOco<_>leptos-rs/leptos#1720](Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
This PR has been generated by Mend Renovate. View repository job log here.