Skip to content

Commit

Permalink
Merge #277
Browse files Browse the repository at this point in the history
277: A new minimal example that work with PR #272 r=DenisKolodin a=limira

It is the example in `src/lib.rs`.

Co-authored-by: Limira <20672976+limira@users.noreply.github.com>
  • Loading branch information
bors[bot] and limira committed Jun 17, 2018
2 parents b0ff1e0 + aa5132f commit bde3612
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,50 @@
//! Minimal example:
//!
//! ```rust
//! #[macro_use]
//! extern crate yew;
//! use yew::html::*;
//!
//! use yew::prelude::*;
//!
//! struct Model {
//! value: i64,
//! }
//!
//!
//! enum Msg {
//! DoIt,
//! }
//!
//! fn update(context: &mut Context<Msg>, model: &mut Model, msg: Msg) {
//! match msg {
//! Msg::DoIt => {
//! model.value = model.value + 1;
//!
//! impl Component for Model {
//! type Message = Msg;
//! type Properties = ();
//! fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
//! Self {
//! value: 0,
//! }
//! }
//!
//! fn update(&mut self, msg: Self::Message) -> ShouldRender {
//! match msg {
//! Msg::DoIt => self.value = self.value + 1
//! }
//! true
//! }
//! }
//!
//! fn view(model: &Model) -> Html<Msg> {
//! html! {
//! <div>
//! <button onclick=|_| Msg::Increment,>{ "Add +1" }</button>
//! <p>{ model.value }</p>
//! </div>
//!
//! impl Renderable<Model> for Model {
//! fn view(&self) -> Html<Self> {
//! html! {
//! <div>
//! <button onclick=|_| Msg::DoIt,>{ "+1" }</button>
//! <p>{ self.value }</p>
//! </div>
//! }
//! }
//! }
//!
//!
//! fn main() {
//! let model = Model {
//! value: 0,
//! };
//! program(model, update, view);
//! yew::initialize();
//! App::<Model>::new().mount_to_body();
//! yew::run_loop();
//! }
//! ```
//!
Expand Down

0 comments on commit bde3612

Please sign in to comment.