v0.1.0 #306
gbj
announced in
Announcements
v0.1.0
#306
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Finally, here's the release for version
0.1.0. Thanks to everyone who's been working with the alpha, beta, and bleeding-edge versions over the last few weeks to help get everything ready.Most of the release notes below are copied from the
0.1.0-alpharelease, but include a few updates. All these changes are relative to0.0.22.Features
More flexible rendering
You can now easily mix and match different types of node in a
Fragment, which previously needed to be aVecof all the same types (like aVec<Fragment>).In fact, the
<>fragment itself is optional.Typed HTML elements
HTML elements generated by the
view!macro are now typed, and implementDerefto give a correctly-typedweb_syselement.store_valueYou can now store non-reactive values in the reactive system to take advantage of the same
Copy + 'staticreference system without the overhead or abstraction leak of storing something in a signal. This is useful for objects you need to reference in multiple places throughout your application without cloning.Signal<T>andSignalSetter<T>abstractionsThese wrappers allow you to define APIs that can take any kind of signal. For example,
Signal<T>can be aReadSignal,RwSignal,Memo, or derived signal. This is especially useful when defining components interfaces. (There's even aMaybeSignalfor types that may just beTor may be aSignal<T>.)Massively improved Rust Analyzer support
DX with this new system is much better. You'll see hugely improved language-server integration for the
view!macro, including features like doc comments for HTML elements, autocompletion for component properties, clicking to go to the definition of a component, type hints for component arguments, etc.Inline documentation in the
#[component]macroYou can now document components and their properties directly in the
#[component]macro like this:The macro will automatically generate docs for the components and for each of its props.
#[prop]attributes for component propsYou can use the
#[prop]attribute macro to mark component props in several ways:#[prop(into)]: This will call.into()on any value passed into the component prop. (For example,you could apply
#[prop(into)]to a prop that takes Signal, which wouldallow users to pass a ReadSignal or RwSignal
and automatically convert it.)
#[prop(optional)]: If the user does not specify this property when they use the component,it will be set to its default value. If the property type is
Option<T>, values should be passedas
name=Tand will be received asSome(T).#[prop(optional_no_strip)]: The same asoptional, but requires values to be passed asNoneorSome(T)explicitly. This means that the optional property can be omitted (and beNone), or explicitlyspecified as either
NoneorSome(T).#[prop(default = X)]: The property is optional, and will be set to the default value provided if it is not passed.tracingsupportWe've added support for debugging using the
tracingcrate, integrated into both the renderer and the reactive system. This means that when an effect or an event listener fires, you can usetrace!(...)to get an insight into the flow of your program. Seeleptos_dom/examples/test-benchfor an example setup; a separate crate to make this tracing setup easier will be forthcoming.cargo-leptosintegration improvementscargo-leptos 0.1.2and the Actix/Axum integrations in0.1.0now work together seamlessly, allowing you to create full-stack applications with as little boilerplate as possible.And much more!
<Router/>in a<div>for no obvious reasonviewmacroBreaking Changes
Here are a few things to watch out for as you migrate:
cargo-leptosalready and run into any issues (for example, with the path of a JS or Wasm file), be sure to check out the latest examples and the starter. The extra structures here have changed a bit over time as we've tried to figure out the best patterns. Cloning the starter and adding your existing application code should work fine.-> impl IntoView<For/>component now takes aviewproperty, instead of you passing the view function as the child of the component<Route/>component takes aviewproperty instead ofelementfor consistencychildrenproperties are now typedBox<dyn Fn(Scope) -> Fragment>view!macro returns distinct structures, which are all different types. In other words, this code no longer compilesbecause the first branch now returns
HtmlElement<P>while the second returnsHtmlElement<Span>.In this case, simply add
.into_any()to each to returnHtmlElement<AnyElement>from both. In general, you can always call.into_view(cx)to return a wrappingViewtype instead.This discussion was created from the release v0.1.0.
Beta Was this translation helpful? Give feedback.
All reactions