Releases: yewstack/yew
v0.9.0
Feature Overload
This release introduces a slew of new features, many of which come from first-time contributors! There's too many to mention so read more below 😄 Also, a long-standing bug was fixed by @hgzimmerman which was causing Component
's to not be destroyed properly.
-
⚡️ Features
-
New
KeyboardService
for setting up key listeners on browsers which support the feature. [@hgzimmerman, #647] -
ComponentLink
can now create aCallback
with more than oneMessage
. TheMessage
's will be batched together so that theComponent
will not be re-rendered more than necessary. [@stkevintan, #660] -
Message
's toPublic
Agent
's will now be queued if theAgent
hasn't finished setting up yet. [@serzhiio, #596] -
Agent
's can now be connected to without aCallback
. Instead of creating a bridge to the agent, create a dispatcher like so:MyAgent::dispatcher()
. [@hgzimmerman, #639] -
Component
's can now accept children in thehtml!
macro. [@jstarry, #589]// app.rs html! { <MyList name="Grocery List"> <MyListItem text="Apples" /> </MyList> }
// my_list.rs use yew::prelude::*; pub struct MyList(Props); #[derive(Properties)] pub struct Props { #[props(required)] pub name: String, pub children: Children<MyListItem>, } impl Renderable<MyList> for MyList { fn view(&self) -> Html<Self> { html! {{ self.props.children.iter().collect::<Html<Self>>() }} } }
-
Iterator
s can now be rendered in thehtml!
macro without using thefor
keyword. [@hgzimmerman, #622]Before:
html! {{ for self.props.items.iter().map(renderItem) }}
After:
html! {{ self.props.items.iter().map(renderItem).collect::<Html<Self>>() }}
-
Closures are now able to be transformed into optional
Callback
properties. [@Wodann, #612] -
Improved CSS class ergonomics with new
Classes
type. [@DenisKolodin, #585], [@hgzimmerman, #626] -
Touch events are now supported
<div ontouchstart=|_| Msg::TouchStart>
[@boydjohnson, #584], [@jstarry, #656] -
The
Component
trait now has anmounted
method which can be implemented to react to when your components have been mounted to the DOM. [@hgzimmerman, #583] -
Additional Fetch options
mode
,cache
, andredirect
are now supported [@davidkna, #579] -
The derive props macro now supports Properties with lifetimes [@jstarry, #580]
-
New
ResizeService
for registering forwindow
size updates [@hgzimmerman, #577]
-
-
🛠 Fixes
- Fixed JS typo in RenderService. This was causing animation frames to not be dropped correctly. [@jstarry, #658]
- Fixed
VNode
orphaning bug when destroyingVTag
elements. This caused someComponent
s to not be properly destroyed when they should have been. [@hgzimmerman, #651] - Fix mishandling of Properties
where
clause in derive_props macro [@astraw, #640]
-
🚨 Breaking changes
None
v0.8.0
Props! Props! Props!
This release introduces a more developer friendly way to handle your Component
props. Use the new #[derive(Properties)]
macro to beef up your props! Property values can now be annotated as #[props(required)]
which will enforce that props are present at compile time. This means that your props struct no longer needs to implement Default
, so time to clean up all of those prop values you wrapped in Option
to have a default value.
-
⚡️ Features
html!
- Self-closing html tags can now be used:<div class="marker" />
[@totorigolo, #523]html!
- SVG name-spaced tags are now supported! [@jstarry, #550]- Properties can now be required at compile time [@jstarry, #553]
- App components can now be mounted with properties [@jstarry, #567]
- Apps can now be mounted as the
<body>
tag [@jstarry, @kellytk, #540] - Content editable elements can now trigger
oninput
events [@tiziano88, #549]
-
🛠 Fixes
html!
- Class name order is now preserved which unlocks the use of Semantic UI [@charvp, #424]html!
- Dashed tag names and properties are supported [@jstarry, #512, #550]html!
- All rust keywords can be used as tag attributes [@jstarry, #550]html!
- SupportCallback
closure with explicit return type [@totorigolo, #564]html!
- Fixed edge case where>
token would break parser [@totorigolo, #565]- Performance improvement to the diff engine [@totorigolo, #539]
Properties
no longer need to implement thePartialEq
,Clone
, orDefault
traits [@jstarry, #553]Component
will not panic if thechange
method is unimplemented [@jstarry, #554]
-
🚨 Breaking changes
-
The
Component::Properties
associated type must implement the newProperties
trait [@jstarry, #553]The new
Properties
trait is what powers the ability to check required props are present at compile time. Use the derive props macro to implement automatically.use yew::Properties; #[derive(Properties)] pub struct Props { #[props(required)] pub value: MyStruct, }
-
Callback
props no longer transform intoOption
types [@jstarry, #553]html! { <Button on_click=Msg::Click /> }
before:
#[derive(PartialEq, Clone, Default)] pub struct Props { on_click: Option<Callback<()>>, }
after: note the
#[props(required)]
attribute#[derive(PartialEq, Properties)] pub struct Props { #[props(required)] on_click: Callback<()>, }
-
v0.7.0
Commas? We don't need no stinkin' commas!
This release brings a new and improved html!
macro for writing JSX-like syntax. Commas and colons are no longer necessary now that the macro is written as a procedural macro.
-
⚡️ Features
html!{}
is now valid syntax and can be used to render nothing [[@jstarry], #500]- Apps can now be built without
cargo-web
usingwasm-bindgen
[[@jstarry], #497] Callback
now implementsDebug
[[@deniskolodin], #485]- New utility method for getting the
host
of the current page [[@deniskolodin], #509]
-
🛠 Fixes
html!
- Commas are no longer necessary for splitting up attributes [[@jstarry], #500]html!
- Colons are no longer necessary for denoting aComponent
tag [[@jstarry], #500]- Textarea value can be now be set:
<textarea value="content">
[[@deniskolodin], #476] - changed
StorageService::restore
to take an immutable receiver [[@dermetfan], #480] - Fixed a component rendering bug [[@jstarry], #502]
v0.6.0
-
⚡️ Features
- Added
start_app
convenience method for initializing the app and mounting it to the body [[@deniskolodin], #462] - Added handling of files of
input
element. There is now aChangeData::Files
variant for theonchange
handler [[@deniskolodin], #464] - Added
ReaderService
to read data fromFile
instances. [[@deniskolodin], #464, #468]
- Added
-
🛠 Fixes
- It was impossible to set
value
attribute for any tag instead ofoption
, because it used
inner value ofVTag
to keep the value forinput
element. Nowvalue
attribute works
foroptions
,progress
tags, etc.
- It was impossible to set
-
🔮 Examples
- New example
file_upload
that prints sizes of uploaded files [[@deniskolodin], #464]
- New example
v0.5.0
🎶 Secret Agent Man 🎶
This release introduces the concept of an Agent
. Agents are separate activities which you could run in the same thread or in a separate thread. There are three types of agents Context
, Job
, Public
described below. To connect to an agent use the Worker::bridge
method and pass a link of component's environment to it.
-
⚡️ Features
- Introduced the concept of an
Agent
which can run processes in other contexts:Context
agent spawns once per threadJob
agent spawns for every bridgePublic
agent spawns an agent in a separate thread (it uses [Web Workers API] under the hood).
- Allow setting the whole properties struct of a component with
<Component: with props />
ComponentLink
now has asend_self
method which allows components to update themselves [[@deniskolodin], #365]- All services are re-exported within the
yew::services
module. html!
macro supports multiple classes in a single string:
<a class="button is-primary",>
.- Added
FetchOptions
to allow settingCredentials
offetch
request. FetchService
aborts requests usingAbortController
.- Added
SubmitEvent
withonsubmit
rule.
- Introduced the concept of an
-
🛠 Fixes
- Bug with emscripten target
RuntimeError: index out of bounds
fixed with a new scheduler [[@deniskolodin], #272]
- Bug with emscripten target
-
🚨 Breaking changes
send_back
method requires a mutable reference toself
. This was added to prevent creating callbacks inview
implementations. [[@deniskolodin], #367]Context
requirement removed. It's no longer necessary to useComponent<CTX>
type parameter. Instead, a link to the environment is provided with theComponent::create
call. [[@deniskolodin], #272]