github leptos-rs/leptos 0.5.0-beta2
v0.5.0-beta2

latest releases: v0.7.0-rc1, v0.7.0-rc0, v0.7.0-gamma3...
pre-release14 months ago

Just another beta release. I'm expecting to release 0.5.0 itself in the next couple weeks, there have just been a couple other small but breaking changes proposed that are working their way through, and I'd rather delay a bit than rush it and be stuck.

0.5.0-beta2 reflects the current state of the main branch. The v0.5.0 in General section is copied and pasted from previous releases. New this Release reflects changes since 0.5.0-beta (I think?).

New this Release

  • Make all arguments to #[server] optional: change default prefix to /api and default to generating a PascalCase type name from the function name
// before
#[server(MyName, "/api")]
pub async fn my_name() /* ... */
// after
#[server]
pub async fn my_name /* ... */
  • create_effect now returns an Effect struct. This exists mostly so you can .dispose() it early if you need. (This may require adding some missing semicolons, as create_effect no longer returns ().)
  • Support passing signals directly as attributes, classes, styles, and props on stable
  • Signal traits now take an associated Value type rather than a generic (see #1578)
  • Many APIs that previously took impl Into<Cow<'static, str>> now take impl 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 the View. 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.)

v0.5.0 in General

Reactive System Changes

This long-awaited release significantly changes how the reactive system works. This should solve several correctness issues/rough edges that related to the manual use of cx/Scope and could create memory leaks. (See #918 for details)

It also has the fairly large DX change (improvement?) of removing the need to pass cx or Scope variables around at all.

Migration is fairly easy. 95% of apps will migrate completely by making the following string replacements:

  1. cx: Scope, => (empty string)
  2. cx: Scope => (empty string)
  3. cx, => (empty string)
  4. (cx) => ()
  5. |cx| => ||
  6. Scope, => (empty string)
  7. Scope => (empty string) as needed
  8. You may have some |_, _| that become |_| or |_| that become ||, particularly for the fallback props on <Show/> and <ErrorBoundary/>

Basically, there is no longer a Scope type, and anything that used to take it can simply be deleted.

For the 5%: if you were doing tricky things like storing a Scope somewhere in a struct or variable and then reusing it, you should be able to achieve the same result by storing Owner::current() somewhere and then later using it in with_owner(owner, move || { /* ... */ }).

There are no other big conceptual or API changes in this update: essentially all the same reactive, templating, and component concepts should still apply, just without cx.

What's Changed

  • change: shift from Scope-based ownership to reactive ownership by @gbj in #918
  • refactor(workflows): extract calls by @agilarity in #1566
  • refactor(verify-changed-examples): improve readability and runtime by @agilarity in #1556
  • Remove Clone requirement for slots in Vec by @Senzaki in #1564
  • fix: INFO is too high a level for this prop tracing by @gbj in #1570
  • fix: suppress warning about non-reactivity when calling .refetch() (occurs in e.g., async blocks in actions) by @gbj in #1576
  • fix: nightly warning in server macro for lifetime by @markcatley in #1580
  • fix: runtime disposal time in render_to_string_async by @gbj in #1574
  • feat: support passing signals directly as attributes, classes, styles, and props on stable by @gbj in #1577
  • feat: make struct name and path optional for server functions by @gbj in #1573
  • support effect dispose by @flisky in #1571
  • fix(counters_stable): restore wasm tests (#1581) by @agilarity in #1582
  • fix: fourth argument to server functions by @gbj in #1585
  • feat: signal traits should take associated types instead of generics by @gbj in #1578
  • refactor(check-stable): use matrix (#1543) by @agilarity in #1583
  • feat: add Fn traits for resources on nightly by @gbj in #1587
  • Convenient event handling with slots by @rkuklik in #1444
  • fix: correct logic for resource loading signal when read outside suspense (closes #1457) by @gbj in #1586
  • Update autoreload websocket connection to work outside of localhost by @rabidpug in #1548
  • Some resource and transition fixes by @gbj in #1588
  • fix: broken test with untrack in tracing props by @gbj in #1593
  • feat: update to typed-builder 0.16 (closes #1455) by @gbj in #1590
  • Oco (Owned Clones Once) smart pointer by @DanikVitek in #1480
  • docs: add docs for builder syntax by @gbj in #1603
  • chore(examples): improve cucumber support #1598 by @agilarity in #1599
  • fix(ci): add new webkit dependency (#1607) by @agilarity in #1608
  • fix(macro/params): clippy warning by @Maneren in #1612
  • Improve server function client side error handling by @drdo in #1597
  • Don't try to parse as JSON the result from a server function redirect by @JonRCahill in #1604
  • fix: add docs on #[server] functions by @realeinherjar in #1610

New Contributors

Full Changelog: v0.4.9...0.5.0-beta2

Don't miss a new leptos release

NewReleases is sending notifications on new releases.