Skip to content

v0.10

Compare
Choose a tag to compare
@jstarry jstarry released this 11 Nov 05:57
· 1636 commits to master since this release
6bc6a30

Back to the...

  • ⚡️ Features

    • Future support 🎉 A Component can update following the completion of a Future. Check out this example to see how it works. This approach was borrowed from a fork of Yew called plaster created by @carlosdp. [@hgzimmerman, #717]
    • Added the agent and services features so that those modules can be disabled (useful if you are switching to using Futures). [@hgzimmerman, #684]
    • Add ref keyword for allowing a Component to have a direct reference to its rendered elements. For example, you can now easily focus an <input> element after mounting. [@jstarry, #715]
    use stdweb::web::html_element::InputElement;
    use stdweb::web::IHtmlElement;
    use yew::*;
    
    pub struct Input {
        node_ref: NodeRef,
    }
    
    impl Component for Input {
        type Message = ();
        type Properties = ();
    
        fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
            Input {
                node_ref: NodeRef::default(),
            }
        }
    
        fn mounted(&mut self) -> ShouldRender {
            if let Some(input) = self.node_ref.try_into::<InputElement>() {
                input.focus();
            }
            false
        }
    
        fn update(&mut self, _: Self::Message) -> ShouldRender {
            false
        }
    
        fn view(&self) -> Html<Self> {
            html! {
                <input ref=self.node_ref.clone() type="text" />
            }
        }
    }
    • Make Agent related types public to allow other crates to create custom agents. [@dunnock, #721]
    • Component::change will now return false for components that have Component::Properties == (). [@kellytk, #690]]
    • Updated wasm-bindgen dependency to 0.2.54. Please update your wasm-bindgen-cli tool by running cargo install --force --version 0.2.54 -- wasm-bindgen-cli. [@jstarry, #730], [@ctaggart, #681]
  • 🛠 Fixes

    • Fixed the mount order of components. The root component will be mounted after all descendants have been mounted. [@jstarry, #725]
    • All public items now implement Debug. [@hgzimmerman, #673]
  • 🚨 Breaking changes

    • Minimum rustc version has been bumped to 1.39.0 for Future support. [@jstarry, #730]

    • Component now has a required view method and automatically implements the Renderable trait. The view method in the Renderable trait has been renamed to render. [@jstarry, #563]

      Before:

      impl Component for Model {
          type Message = Msg;
          type Properties = ();
      
          fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
              Model {}
          }
      
          fn update(&mut self, msg: Self::Message) -> ShouldRender {
              true
          }
      }
      
      impl Renderable<Model> for Model {
          fn view(&self) -> Html<Self> {
              html! { "hello" }
          }
      }

      After:

      impl Component for Model {
          type Message = Msg;
          type Properties = ();
      
          fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
              Model {}
          }
      
          fn update(&mut self, msg: Self::Message) -> ShouldRender {
              true
          }
      
          fn view(&self) -> Html<Self> {
              html! { "hello" }
          }
      }
    • Removed the Transferable trait since it did no more than extend the serde Serialize and Deserialize traits. [@hgzimmerman, #319]

      Before:

      impl Transferable for Input {}
      #[derive(Serialize, Deserialize)]
      pub enum Input {
        Connect,
      }

      After:

      #[derive(Serialize, Deserialize)]
      pub enum Input {
        Connect,
      }
    • WebSocketService::connect will now return a Result in order to stop panicking on malformed urls. [@lizhaoxian, #727]

    • VTag now is boxed within VNode to shrink the size of its enum representation. [@hgzimmerman, #675]