yew v0.9 Release Notes

Release Date: 2019-09-27 // over 4 years ago
    • ⚡️ Features

      • New KeyboardService for setting up key listeners on browsers which support the feature. [[@hgzimmerman], #647]
      • ComponentLink can now create a Callback with more than one Message. The Message's will be batched together so that the Component will not be re-rendered more than necessary. [[@stkevintan], #660]
      • Message's to Public Agent's will now be queued if the Agent hasn't finished setting up yet. [[@serzhiio], #596]
      • Agent's can now be connected to without a Callback. Instead of creating a bridge to the agent, create a dispatcher like so: MyAgent::dispatcher(). [[@hgzimmerman], #639]
      • Component's can now accept children in the html! 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>>()
          }}
        }
      }
      
      • Iterators can now be rendered in the html! macro without using the for 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 an mounted method which can be implemented to react to when your components have been mounted to the DOM. [[@hgzimmerman], #583]
      • Additional Fetch options mode, cache, and redirect are now supported [[@davidkna], #579]
      • The derive props macro now supports Properties with lifetimes [[@jstarry], #580]
      • New ResizeService for registering for window 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 destroying VTag elements. This caused some Components 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