Skip to content

Commit

Permalink
Update all examples to Rust 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
therustmonk committed Feb 2, 2019
1 parent f99692d commit 6de54c1
Show file tree
Hide file tree
Showing 54 changed files with 91 additions and 160 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ serde_json = "1.0"
bincode = "1.0"
anymap = "0.12"
slab = "0.4"
stdweb = "^0.4.9"
stdweb = "^0.4.13"
toml = { version = "0.4", optional = true }
serde_yaml = { version = "0.8.3", optional = true }
rmp-serde = { version = "0.13.7", optional = true }
Expand Down
1 change: 1 addition & 0 deletions examples/counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "counter"
version = "0.1.1"
authors = ["Denis Kolodin <deniskolodin@gmail.com>"]
edition = "2018"

[dependencies]
stdweb = "0.4.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use stdweb::web::Date;
use yew::{html, Component, ComponentLink, Renderable, ShouldRender};
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};
use yew::services::ConsoleService;

pub struct Model {
Expand Down
1 change: 1 addition & 0 deletions examples/crm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "crm"
version = "0.1.0"
authors = ["Denis Kolodin <deniskolodin@gmail.com>"]
edition = "2018"

[dependencies]
serde = "1"
Expand Down
6 changes: 1 addition & 5 deletions examples/crm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate yew;

extern crate pulldown_cmark;

mod markdown;

use yew::prelude::*;
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};
use yew::format::Json;
use yew::services::{DialogService, StorageService};
use yew::services::storage::Area;
Expand Down
3 changes: 1 addition & 2 deletions examples/crm/src/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
/// Source: https://github.com/acmumn/mentoring/blob/master/web-client/src/view/markdown.rs
use pulldown_cmark::{Alignment, Event, Parser, Tag, OPTION_ENABLE_TABLES};
use yew::html::Html;
use yew::html::Component;
use yew::{html, Component, Html};
use yew::virtual_dom::{VNode, VTag, VText};

/// Renders a string of Markdown to HTML with the default options (footnotes
Expand Down
1 change: 1 addition & 0 deletions examples/custom_components/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "custom_components"
version = "0.1.0"
authors = ["Denis Kolodin <deniskolodin@gmail.com>"]
edition = "2018"

[dependencies]
yew = { path = "../.." }
4 changes: 2 additions & 2 deletions examples/custom_components/src/barrier.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use yew::prelude::*;
use button::Button;
use crate::button::Button;
use yew::{html, Callback, Component, ComponentLink, Html, Renderable, ShouldRender};

pub struct Barrier {
limit: u32,
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_components/src/button.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use yew::prelude::*;
use yew::{html, Callback, Component, ComponentLink, Html, Renderable, ShouldRender};

pub struct Button {
title: String,
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_components/src/counter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use yew::prelude::*;
use yew::{html, Callback, Component, ComponentLink, Html, Renderable, ShouldRender};

#[derive(PartialEq, Clone)]
pub enum Color {
Expand Down
5 changes: 1 addition & 4 deletions examples/custom_components/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#[macro_use]
extern crate yew;

mod counter;
mod button;
mod barrier;

use yew::prelude::*;
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};
use counter::{Counter, Color};
use barrier::Barrier;

Expand Down
1 change: 1 addition & 0 deletions examples/dashboard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "dashboard"
version = "0.1.0"
authors = ["Denis Kolodin <deniskolodin@gmail.com>"]
edition = "2018"

[dependencies]
failure = "0.1"
Expand Down
9 changes: 2 additions & 7 deletions examples/dashboard/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
extern crate failure;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate yew;

use failure::Error;
use yew::prelude::*;
use serde_derive::{Deserialize, Serialize};
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};
use yew::format::{Nothing, Json, Toml};
use yew::services::Task;
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
Expand Down
1 change: 1 addition & 0 deletions examples/fragments/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "fragments"
version = "0.1.0"
authors = ["Denis Kolodin <deniskolodin@gmail.com>"]
edition = "2018"

[dependencies]
yew = { path = "../.." }
5 changes: 1 addition & 4 deletions examples/fragments/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#[macro_use]
extern crate yew;

use yew::prelude::*;
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};

pub struct Model {
counter: usize,
Expand Down
5 changes: 2 additions & 3 deletions examples/game_of_life/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ version = "0.1.3"
authors = ["Diego Cardoso <dige0card0s0@hotmail.com>",
"Ilya Bogdanov <fumlead@gmail.com",
"Junjie Huang <huangjj.27@qq.com>"]
edition = "2018"

[dependencies]
# Temporary check
rand = { git = "https://github.com/rust-lang-nursery/rand", features = ["stdweb"] }
#rand = { version = "0.5.0-pre.1", features = ["stdweb"] }
rand = { version = "0.6.5", features = ["stdweb"] }
log = "0.4"
web_logger = "0.1"
yew = { path = "../.." }
8 changes: 2 additions & 6 deletions examples/game_of_life/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#![recursion_limit="128"]

extern crate rand;
#[macro_use] extern crate log;
extern crate web_logger;
#[macro_use] extern crate yew;

use log::info;
use std::time::Duration;
use rand::Rng;
use yew::prelude::*;
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};
use yew::services::{IntervalService, Task};

#[derive(Clone, Copy, PartialEq)]
Expand Down
7 changes: 4 additions & 3 deletions examples/game_of_life/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use log::trace;
use yew::prelude::*;
use game_of_life::{Model, Msg};
use log::trace;
use yew::App;

fn main() {
web_logger::init();
trace!("Initializing yew...");
yew::initialize();
App::<game_of_life::Model>::new().mount_to_body()
App::<Model>::new()
.mount_to_body()
.send_message(Msg::Random);
yew::run_loop();
}
1 change: 1 addition & 0 deletions examples/inner_html/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "inner_html"
version = "0.1.0"
authors = ["Garrett Berg <vitiral@gmail.com>"]
edition = "2018"

[dependencies]
stdweb = "0.4.2"
Expand Down
4 changes: 1 addition & 3 deletions examples/inner_html/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#![recursion_limit="512"]
#[macro_use]
extern crate stdweb;
extern crate yew;

use yew::prelude::*;

use stdweb::web::Node;
use stdweb::unstable::TryFrom;
use yew::{Component, ComponentLink, Html, Renderable, ShouldRender};
use yew::virtual_dom::VNode;

pub struct Model {
Expand Down
1 change: 1 addition & 0 deletions examples/js_callback/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "js_callback"
version = "0.1.0"
authors = ["Scott Steele <scottlsteele@gmail.com>"]
edition = "2018"

[dependencies]
yew = { path = "../.." }
Expand Down
6 changes: 2 additions & 4 deletions examples/js_callback/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#![deny(warnings)]

#[macro_use]
extern crate yew;
use yew::prelude::*;

#[macro_use]
extern crate stdweb;

use yew::{html, Callback, Component, ComponentLink, Html, Renderable, ShouldRender};

pub struct Model {
payload: String,
// Pointless field just to have something that's been manipulated
Expand Down
1 change: 1 addition & 0 deletions examples/large_table/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "large_table"
version = "0.1.0"
authors = ["qthree <qthree3@gmail.com>"]
edition = "2018"

[dependencies]
yew = { path = "../.." }
5 changes: 1 addition & 4 deletions examples/large_table/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
//! This demo originally created by https://github.com/qthree
//! Source: https://github.com/qthree/yew_table100x100_test
#[macro_use]
extern crate yew;

use yew::prelude::*;
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};

pub struct Model {
selected: Option<(u32, u32)>
Expand Down
1 change: 1 addition & 0 deletions examples/mount_point/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "mount_point"
version = "0.1.0"
authors = ["Ben Berman <ben@standardbots.com>"]
edition = "2018"

[dependencies]
stdweb = "0.4"
Expand Down
5 changes: 1 addition & 4 deletions examples/mount_point/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#[macro_use]
extern crate yew;

use yew::prelude::*;
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};

pub struct Model {
name: String,
Expand Down
5 changes: 4 additions & 1 deletion examples/mount_point/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#[macro_use]
extern crate stdweb;

use yew::App;
use stdweb::web::{js, IElement, INode, IParentNode, document};
use stdweb::web::{IElement, INode, IParentNode, document};
use mount_point::Model;

fn main() {
Expand Down
1 change: 1 addition & 0 deletions examples/multi_thread/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "multi_thread"
version = "0.1.0"
authors = ["Denis Kolodin <deniskolodin@gmail.com>"]
edition = "2018"

[dependencies]
log = "0.4"
Expand Down
11 changes: 1 addition & 10 deletions examples/multi_thread/src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
extern crate web_logger;
extern crate yew;
extern crate multi_thread;

use yew::prelude::*;
use multi_thread::Model;

fn main() {
web_logger::init();
yew::initialize();
App::<Model>::new().mount_to_body();
yew::run_loop();
yew::start_app::<multi_thread::Model>();
}
10 changes: 2 additions & 8 deletions examples/multi_thread/src/bin/native_worker.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@

extern crate web_logger;
extern crate yew;
extern crate multi_thread;

use yew::prelude::*;
use multi_thread::native_worker;
use yew::agent::Threaded;

fn main() {
web_logger::init();
yew::initialize();
native_worker::Worker::register();
multi_thread::native_worker::Worker::register();
yew::run_loop();
}
4 changes: 3 additions & 1 deletion examples/multi_thread/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use log::info;
use serde_derive::{Deserialize, Serialize};
use std::time::Duration;
use yew::prelude::worker::*;
use yew::worker::*;
// TODO use yew::services::{IntervalService, FetchService, Task};
use yew::services::Task;
use yew::services::interval::IntervalService;
Expand Down
4 changes: 3 additions & 1 deletion examples/multi_thread/src/job.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use log::info;
use serde_derive::{Deserialize, Serialize};
use std::time::Duration;
use yew::prelude::worker::*;
use yew::worker::*;
// TODO use yew::services::{IntervalService, FetchService, Task};
use yew::services::Task;
use yew::services::interval::IntervalService;
Expand Down
11 changes: 3 additions & 8 deletions examples/multi_thread/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate yew;

pub mod native_worker;
pub mod job;
pub mod context;

use yew::prelude::*;
use log::info;
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};
use yew::worker::*;

pub struct Model {
worker: Box<Bridge<native_worker::Worker>>,
Expand Down
4 changes: 3 additions & 1 deletion examples/multi_thread/src/native_worker.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use log::info;
use std::time::Duration;
use yew::prelude::worker::*;
use serde_derive::{Deserialize, Serialize};
use yew::worker::*;
// TODO use yew::services::{IntervalService, FetchService, Task};
use yew::services::Task;
use yew::services::interval::IntervalService;
Expand Down
1 change: 1 addition & 0 deletions examples/npm_and_rest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "npm_and_rest"
version = "0.1.0"
authors = ["Denis Kolodin <deniskolodin@gmail.com>"]
edition = "2018"

[dependencies]
failure = "0.1"
Expand Down
3 changes: 2 additions & 1 deletion examples/npm_and_rest/src/gravatar.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use failure::Error;
use failure::{format_err, Error};
use serde_derive::Deserialize;
use yew::callback::Callback;
use yew::format::{Json, Nothing};
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
Expand Down
8 changes: 1 addition & 7 deletions examples/npm_and_rest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
#[macro_use]
extern crate failure;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate stdweb;
#[macro_use]
extern crate yew;

// Own services implementation
pub mod gravatar;
pub mod ccxt;

use failure::Error;
use yew::prelude::*;
use yew::{html, Callback, Component, ComponentLink, Html, Renderable, ShouldRender};
use yew::services::fetch::FetchTask;

use gravatar::{GravatarService, Profile};
Expand Down
Loading

0 comments on commit 6de54c1

Please sign in to comment.