Skip to content

Commit 0e52b88

Browse files
author
mc1098
authored
Update gloo dependencies in yew and examples (yewstack#2021)
Updates to using the latest stable gloo, in some cases removing dependencies on `master` branch. Removes `weblog` in favour of `gloo_console`, where applicable.
1 parent 68d2fdb commit 0e52b88

File tree

31 files changed

+56
-58
lines changed

31 files changed

+56
-58
lines changed

examples/boids/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ getrandom = { version = "0.2", features = ["js"] }
1212
rand = "0.8"
1313
serde = { version = "1.0", features = ["derive"] }
1414
yew = { path = "../../packages/yew" }
15-
gloo = { git = "https://github.com/rustwasm/gloo/" }
15+
gloo = "0.3"

examples/counter/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
license = "MIT OR Apache-2.0"
77

88
[dependencies]
9+
gloo-console = "0.1"
910
js-sys = "0.3"
1011
yew = { path = "../../packages/yew" }
11-
weblog = "0.3"
1212
wasm-bindgen = "0.2"

examples/counter/src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use gloo_console as console;
12
use js_sys::Date;
2-
use weblog::console_log;
33
use yew::{html, Component, Context, Html};
44

55
// Define the possible messages which can be sent to the component
@@ -24,12 +24,12 @@ impl Component for Model {
2424
match msg {
2525
Msg::Increment => {
2626
self.value += 1;
27-
console_log!("plus one"); // Will output a string to the browser console
27+
console::log!("plus one"); // Will output a string to the browser console
2828
true // Return true to cause the displayed change to update
2929
}
3030
Msg::Decrement => {
3131
self.value -= 1;
32-
console_log!("minus one");
32+
console::log!("minus one");
3333
true
3434
}
3535
}

examples/crm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ license = "MIT OR Apache-2.0"
99
serde = "1"
1010
serde_derive = "1"
1111
yew = { path = "../../packages/yew" }
12-
gloo = { git = "https://github.com/rustwasm/gloo/" }
12+
gloo = "0.3"
1313

examples/dyn_create_destroy_apps/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ license = "MIT OR Apache-2.0"
99
js-sys = "0.3"
1010
yew = { path = "../../packages/yew" }
1111
slab = "0.4.3"
12-
gloo = "0.2"
12+
gloo = "0.3"
1313
wasm-bindgen = "0.2"
14-
weblog = "0.3"
1514

1615
[dependencies.web-sys]
1716
version = "0.3.50"

examples/dyn_create_destroy_apps/src/counter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gloo::timers::callback::Interval;
1+
use gloo::{console, timers::callback::Interval};
22
use yew::prelude::*;
33

44
pub struct CounterModel {
@@ -61,6 +61,6 @@ impl Component for CounterModel {
6161
}
6262

6363
fn destroy(&mut self, _ctx: &Context<Self>) {
64-
weblog::console_log!("CounterModel app destroyed");
64+
console::log!("CounterModel app destroyed");
6565
}
6666
}

examples/file_upload/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
88
[dependencies]
99
js-sys = "0.3"
1010
yew = { path = "../../packages/yew" }
11-
gloo = "0.2"
11+
gloo-file = "0.1"
1212

1313
[dependencies.web-sys]
1414
version = "0.3"

examples/file_upload/src/main.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use web_sys::{Event, HtmlInputElement};
22
use yew::{html, html::TargetCast, Component, Context, Html};
33

4-
use gloo::file::callbacks::FileReader;
5-
use gloo::file::File;
4+
use gloo_file::callbacks::FileReader;
5+
use gloo_file::File;
66

77
type Chunks = bool;
88

@@ -50,14 +50,14 @@ impl Component for Model {
5050
let link = ctx.link().clone();
5151

5252
if bytes {
53-
gloo::file::callbacks::read_as_bytes(&file, move |res| {
53+
gloo_file::callbacks::read_as_bytes(&file, move |res| {
5454
link.send_message(Msg::LoadedBytes(
5555
file_name,
5656
res.expect("failed to read file"),
5757
))
5858
})
5959
} else {
60-
gloo::file::callbacks::read_as_text(&file, move |res| {
60+
gloo_file::callbacks::read_as_text(&file, move |res| {
6161
link.send_message(Msg::Loaded(
6262
file_name,
6363
res.unwrap_or_else(|e| e.to_string()),

examples/game_of_life/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ log = "0.4"
1515
rand = "0.8"
1616
wasm-logger = "0.2"
1717
yew = { path = "../../packages/yew" }
18-
gloo = "0.2"
18+
gloo-timers = "0.2"

examples/game_of_life/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use cell::Cellule;
2-
use gloo::timers::callback::Interval;
2+
use gloo_timers::callback::Interval;
33
use rand::Rng;
44
use yew::html::Scope;
55
use yew::{classes, html, Component, Context, Html};

examples/multi_thread/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ serde = { version = "1.0", features = ["derive"] }
1111
wasm-logger = "0.2"
1212
yew = { path = "../../packages/yew" }
1313
yew-agent = { path = "../../packages/yew-agent" }
14-
gloo = "0.2"
14+
gloo-timers = "0.2"

examples/multi_thread/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gloo::timers::callback::Interval;
1+
use gloo_timers::callback::Interval;
22
use serde::{Deserialize, Serialize};
33
use yew_agent::{Agent, AgentLink, Context, HandlerId};
44

examples/multi_thread/src/job.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gloo::timers::callback::Interval;
1+
use gloo_timers::callback::Interval;
22
use serde::{Deserialize, Serialize};
33
use yew_agent::{Agent, AgentLink, HandlerId, Job};
44

examples/multi_thread/src/native_worker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gloo::timers::callback::Interval;
1+
use gloo_timers::callback::Interval;
22
use serde::{Deserialize, Serialize};
33
use yew_agent::{Agent, AgentLink, HandlerId, Public};
44

examples/pub_sub/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ edition = "2018"
55
license = "MIT OR Apache-2.0"
66

77
[dependencies]
8-
log = "0.4"
98
serde = { version = "1.0", features = ["derive"] }
10-
wasm-logger = "0.2.0"
119
yew = { path = "../../packages/yew" }
1210
yew-agent = { path = "../../packages/yew-agent" }

examples/router/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ yew = { path = "../../packages/yew" }
1515
yew-router = { path = "../../packages/yew-router" }
1616
serde = { version = "1.0", features = ["derive"] }
1717
lazy_static = "1.4.0"
18-
gloo = "0.2"
18+
gloo-timers = "0.2"

examples/router/src/components/progress_delay.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gloo::timers::callback::Interval;
1+
use gloo_timers::callback::Interval;
22
use instant::Instant;
33
use yew::prelude::*;
44

examples/store/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ license = "MIT OR Apache-2.0"
88
[dependencies]
99
yew = { path = "../../packages/yew" }
1010
yew-agent = { path = "../../packages/yew-agent" }
11-
weblog = "0.3"
1211
wasm-bindgen = "0.2"
12+
gloo-console = "0.1"

examples/store/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ mod post;
33
mod text_input;
44

55
use agents::posts::{PostId, PostRequest, PostStore};
6+
use gloo_console as console;
67
use post::Post;
78
use text_input::TextInput;
8-
use weblog::console_log;
99
use yew::prelude::*;
1010
use yew_agent::utils::store::{Bridgeable, ReadOnly, StoreWrapper};
1111
use yew_agent::Bridge;
@@ -41,7 +41,7 @@ impl Component for Model {
4141
Msg::PostStoreMsg(state) => {
4242
// We can see this is logged once before we click any button.
4343
// The state of the store is sent when we open a bridge.
44-
console_log!("Received update");
44+
console::log!("Received update");
4545

4646
let state = state.borrow();
4747
if state.posts.len() != self.post_ids.len() {

examples/timer/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ license = "MIT OR Apache-2.0"
88
[dependencies]
99
yew = { path = "../../packages/yew" }
1010
js-sys = "0.3"
11-
gloo = "0.2"
12-
weblog = "0.3"
11+
gloo = "0.3"
1312
wasm-bindgen = "0.2"

examples/timer/src/main.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use gloo::console_timer::ConsoleTimer;
2-
use gloo::timers::callback::{Interval, Timeout};
3-
use weblog::*;
1+
use gloo::{
2+
console::{self, Timer},
3+
timers::callback::{Interval, Timeout},
4+
};
45
use yew::{html, Component, Context, Html};
56

67
pub enum Msg {
@@ -18,7 +19,7 @@ pub struct Model {
1819
_standalone: (Interval, Interval),
1920
interval: Option<Interval>,
2021
timeout: Option<Timeout>,
21-
console_timer: Option<ConsoleTimer<'static>>,
22+
console_timer: Option<Timer<'static>>,
2223
}
2324

2425
impl Model {
@@ -39,7 +40,7 @@ impl Component for Model {
3940

4041
fn create(ctx: &Context<Self>) -> Self {
4142
let standalone_handle =
42-
Interval::new(10, || console_debug!("Example of a standalone callback."));
43+
Interval::new(10, || console::debug!("Example of a standalone callback."));
4344

4445
let clock_handle = {
4546
let link = ctx.link().clone();
@@ -67,10 +68,10 @@ impl Component for Model {
6768
self.timeout = Some(handle);
6869

6970
self.messages.clear();
70-
console_clear!();
71+
console::clear!();
7172

7273
self.messages.push("Timer started!");
73-
self.console_timer = Some(ConsoleTimer::new("Timer"));
74+
self.console_timer = Some(Timer::new("Timer"));
7475
true
7576
}
7677
Msg::StartInterval => {
@@ -81,15 +82,15 @@ impl Component for Model {
8182
self.interval = Some(handle);
8283

8384
self.messages.clear();
84-
console_clear!();
85+
console::clear!();
8586

8687
self.messages.push("Interval started!");
8788
true
8889
}
8990
Msg::Cancel => {
9091
self.cancel();
9192
self.messages.push("Canceled!");
92-
console_warn!("Canceled!");
93+
console::warn!("Canceled!");
9394
true
9495
}
9596
Msg::Done => {
@@ -98,7 +99,7 @@ impl Component for Model {
9899

99100
// todo weblog
100101
// ConsoleService::group();
101-
console_info!("Done!");
102+
console::info!("Done!");
102103
if let Some(timer) = self.console_timer.take() {
103104
drop(timer);
104105
}

examples/todomvc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ strum_macros = "0.21"
1111
serde = "1"
1212
serde_derive = "1"
1313
yew = { path = "../../packages/yew" }
14-
gloo = { git = "https://github.com/rustwasm/gloo/" }
14+
gloo = "0.3"

examples/webgl/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
99
js-sys = "0.3"
1010
wasm-bindgen = "0.2"
1111
yew = { path = "../../packages/yew" }
12-
gloo-render = { git = "https://github.com/rustwasm/gloo/" }
12+
gloo-render = "0.1"
1313

1414
[dependencies.web-sys]
1515
version = "0.3"

packages/yew-agent/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ edition = "2018"
99
[dependencies]
1010
anymap = "0.12"
1111
bincode = { version = "1" }
12+
gloo-console = "0.1.0"
1213
js-sys = "0.3"
13-
log = "0.4"
1414
serde = { version = "1.0", features = ["derive"] }
1515
slab = "0.4"
1616
wasm-bindgen = "0.2"

packages/yew-agent/src/pool.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::*;
2-
use log::warn;
2+
use gloo_console as console;
33
use slab::Slab;
44
use yew::scheduler::Shared;
55

@@ -20,14 +20,17 @@ pub(crate) fn locate_callback_and_respond<AGN: Agent>(
2020
match slab.get(id.raw_id()).cloned() {
2121
Some(callback) => callback,
2222
None => {
23-
warn!("Id of handler does not exist in the slab: {}.", id.raw_id());
23+
console::warn!(format!(
24+
"Id of handler does not exist in the slab: {}.",
25+
id.raw_id()
26+
));
2427
return;
2528
}
2629
}
2730
};
2831
match callback {
2932
Some(callback) => callback.emit(output),
30-
None => warn!("The Id of the handler: {}, while present in the slab, is not associated with a callback.", id.raw_id()),
33+
None => console::warn!(format!("The Id of the handler: {}, while present in the slab, is not associated with a callback.", id.raw_id())),
3134
}
3235
}
3336

packages/yew-router/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ yew-router-macro = { path = "../yew-router-macro" }
1616

1717
wasm-bindgen = "0.2"
1818
js-sys = "0.3"
19-
weblog = "0.3.0"
20-
gloo = "0.2.1"
19+
gloo = "0.3.0"
2120
route-recognizer = "0.3.0"
2221
serde = "1.0"
2322
serde_urlencoded = "0.7"

packages/yew-router/src/router.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Router Component.
22
33
use crate::Routable;
4-
use gloo::events::EventListener;
4+
use gloo::{console, events::EventListener};
55
use std::marker::PhantomData;
66
use std::rc::Rc;
77
use yew::prelude::*;
@@ -103,7 +103,7 @@ where
103103
match route {
104104
Some(route) => (ctx.props().render.0)(&route),
105105
None => {
106-
weblog::console_warn!("no route matched");
106+
console::warn!("no route matched");
107107
html! {}
108108
}
109109
}

packages/yew/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ description = "A framework for making client-side single-page apps"
1919
anyhow = "1"
2020
anymap = "0.12"
2121
console_error_panic_hook = "0.1"
22-
gloo = "0.2.1"
22+
gloo = "0.3"
2323
http = "0.2"
2424
indexmap = { version = "1.5", features = ["std"] }
2525
js-sys = "0.3"
26-
log = "0.4"
2726
serde = { version = "1.0", features = ["derive"] }
2827
serde_json = "1.0"
2928
slab = "0.4"

packages/yew/src/virtual_dom/vnode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use super::{Key, VChild, VComp, VDiff, VList, VTag, VText};
44
use crate::html::{AnyScope, Component, NodeRef};
5-
use log::warn;
5+
use gloo::console;
66
use std::cmp::PartialEq;
77
use std::fmt;
88
use std::iter::FromIterator;
@@ -91,7 +91,7 @@ impl VDiff for VNode {
9191
VNode::VList(ref mut vlist) => vlist.detach(parent),
9292
VNode::VRef(ref node) => {
9393
if parent.remove_child(node).is_err() {
94-
warn!("Node not found to remove VRef");
94+
console::warn!("Node not found to remove VRef");
9595
}
9696
}
9797
}

packages/yew/src/virtual_dom/vtag.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use super::{Apply, AttrValue, Attributes, Key, Listener, Listeners, VDiff, VList, VNode};
44
use crate::html::{AnyScope, IntoPropValue, NodeRef};
55
use crate::utils::document;
6-
use log::warn;
6+
use gloo::console;
77
use std::borrow::Cow;
88
use std::cmp::PartialEq;
99
use std::hint::unreachable_unchecked;
@@ -474,7 +474,7 @@ impl VDiff for VTag {
474474
children.detach(&node);
475475
}
476476
if parent.remove_child(&node).is_err() {
477-
warn!("Node not found to remove VTag");
477+
console::warn!("Node not found to remove VTag");
478478
}
479479
self.node_ref.set(None);
480480
}

0 commit comments

Comments
 (0)