Skip to content

Commit ab76a44

Browse files
ranilejstarry
andauthored
Move yew/services to yew-services crate (yewstack#1693)
* move yew/services to yew-services crate * fix stdweb examples * remove services feature usage from workflow * attempt at making CI pass * remove unused feature * add feature i missed during merge * okay, it should compile now * apply review * fix yew-stdweb & aplease fmt * misc fixes Co-authored-by: Justin Starry <justin.starry@icloud.com>
1 parent e5eda4e commit ab76a44

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+345
-180
lines changed

.github/workflows/pull-request.yml

+12-9
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ jobs:
125125
# To fix this we just run them on yew but with yew-stdweb's default features enabled.
126126
cd packages/yew
127127
cargo test --doc \
128-
--no-default-features --features "services agent std_web" \
128+
--no-default-features --features "agent std_web" \
129129
--features "doc_test wasm_test yaml msgpack cbor toml"
130130
131131
integration_tests:
@@ -171,27 +171,30 @@ jobs:
171171
cargo-${{ runner.os }}-
172172
173173
- name: Run tests - yew
174-
env:
175-
HTTPBIN_URL: "http://localhost:8080"
176-
ECHO_SERVER_URL: "ws://localhost:8081"
177174
run: |
178175
cd packages/yew
179-
wasm-pack test --chrome --firefox --headless -- --features "wasm_test httpbin_test echo_server_test"
176+
wasm-pack test --chrome --firefox --headless -- --features "wasm_test"
180177
181178
- name: Run tests - yew-stdweb
182179
if: matrix.toolchain != 'stable'
183-
env:
184-
HTTPBIN_URL: "http://localhost:8080"
185-
ECHO_SERVER_URL: "ws://localhost:8081"
186180
run: |
187181
cd packages/yew-stdweb
188-
wasm-pack test --chrome --firefox --headless -- --features "wasm_test httpbin_test echo_server_test"
182+
wasm-pack test --chrome --firefox --headless -- --features "wasm_test"
189183
190184
- name: Run tests - yew-functional
191185
run: |
192186
cd packages/yew-functional
193187
wasm-pack test --chrome --firefox --headless
194188
189+
- name: Run tests - yew-services
190+
env:
191+
HTTPBIN_URL: "http://localhost:8080"
192+
ECHO_SERVER_URL: "ws://localhost:8081"
193+
run: |
194+
cd packages/yew-services
195+
wasm-pack test --chrome --firefox --headless -- --features "wasm_test httpbin_test echo_server_test"
196+
197+
195198
unit_tests:
196199
name: Unit Tests on ${{ matrix.toolchain }}
197200
runs-on: ubuntu-latest

docs/concepts/services/fetch.md

+5-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub type Binary = Result<Vec<u8>, Error>;
2626
Here is what a typical GET request will look like:
2727
```rust
2828
use yew::format::Nothing;
29-
use yew::services::fetch::Request;
29+
use yew_services::fetch::Request;
3030
let get_request = Request::get("https://example.com/api/v1/get/something")
3131
.body(Nothing)
3232
.expect("Could not build that request");
@@ -36,7 +36,7 @@ Here is what a typical POST request will look like:
3636
```rust
3737
use serde_json::json;
3838
use yew::format::Json;
39-
use yew::services::fetch::Request;
39+
use yew_services::fetch::Request;
4040
let post_request = Request::post("https://example.com/api/v1/post/something")
4141
.header("Content-Type", "application/json")
4242
.body(Json(&json!({"key": "value"})))
@@ -94,11 +94,8 @@ An illustrated example of how to fetch data from an API giving information about
9494
// requires the serde and anyhow crates
9595

9696
use serde::Deserialize;
97-
use yew::{
98-
format::{Json, Nothing},
99-
prelude::*,
100-
services::fetch::{FetchService, FetchTask, Request, Response},
101-
};
97+
use yew::{format::{Json, Nothing}, prelude::*};
98+
use yew_services::fetch::{FetchService, FetchTask, Request, Response};
10299

103100
#[derive(Deserialize, Debug, Clone)]
104101
pub struct ISSPosition {
@@ -241,7 +238,7 @@ The Rust Wasm Book also contains [useful debugging tips](https://rustwasm.github
241238
for Wasm applications.
242239

243240
## Further reading
244-
* [The API documentation](https://docs.rs/yew/0.14.3/yew/services/fetch/index.html)
241+
* [The API documentation](https://docs.rs/yew-services/latest/yew_services/fetch/index.html)
245242
* The [dashboard](https://github.com/yewstack/yew/tree/master/examples/dashboard) and
246243
[npm_and_rest](https://github.com/yewstack/yew/tree/master/examples/web_sys/npm_and_rest) examples.
247244
* [The Rust Wasm Book on debugging Wasm applications](https://rustwasm.github.io/book/reference/debugging.html)

docs/more/debugging.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ fn main() {
3232
log::info!("Update: {:?}", msg);
3333
```
3434

35-
### [`ConsoleService`](https://docs.rs/yew/latest/yew/services/console/struct.ConsoleService.html)
35+
### [`ConsoleService`](https://docs.rs/yew-services/latest/yew_services/struct.ConsoleService.html)
3636

37-
This service is included within Yew and is available when the "services" feature is enabled
38-
(the "services" feature is enabled by default):
37+
This service is included within the [`yew-services`](https://crates.io/crates/yew-services) crate:
3938

4039
```rust
4140
// usage

examples/boids/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ getrandom = { version = "0.2", features = ["js"] }
1111
rand = "0.8"
1212
serde = { version = "1.0", features = ["derive"] }
1313
yew = { path = "../../packages/yew" }
14+
yew-services = { path = "../../packages/yew-services" }

examples/boids/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ The example uses [`IntervalService`] to drive the game loop.
3030
- Resize the boids when "Spacing" is changed.
3131
The setting should then also be renamed to something like "Size".
3232

33-
[`intervalservice`]: https://docs.rs/yew/latest/yew/services/struct.IntervalService.html
33+
[`intervalservice`]: https://docs.rs/yew-services/latest/yew_services/struct.IntervalService.html

examples/boids/src/settings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use serde::{Deserialize, Serialize};
22
use yew::format::Json;
3-
use yew::services::storage::{Area, StorageService};
3+
use yew_services::storage::{Area, StorageService};
44

55
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
66
pub struct Settings {

examples/boids/src/simulation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use crate::boid::Boid;
22
use crate::math::Vector2D;
33
use crate::settings::Settings;
44
use std::time::Duration;
5-
use yew::services::interval::{IntervalService, IntervalTask};
65
use yew::{html, Component, ComponentLink, Html, Properties, ShouldRender};
6+
use yew_services::interval::{IntervalService, IntervalTask};
77

88
pub const SIZE: Vector2D = Vector2D::new(1600.0, 1000.0);
99

examples/counter/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ edition = "2018"
77
[dependencies]
88
js-sys = "0.3"
99
yew = { path = "../../packages/yew" }
10+
yew-services = { path = "../../packages/yew-services" }

examples/counter/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use js_sys::Date;
2-
use yew::services::ConsoleService;
32
use yew::{html, Component, ComponentLink, Html, ShouldRender};
3+
use yew_services::ConsoleService;
44

55
pub enum Msg {
66
Increment,

examples/crm/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ edition = "2018"
88
serde = "1"
99
serde_derive = "1"
1010
yew = { path = "../../packages/yew" }
11+
yew-services = { path = "../../packages/yew-services" }

examples/crm/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For a much more sophisticated approach check out [`yew-router`](https://yew.rs/d
1414
One major flaw with the implementation used by this example is that the scenes aren't tied to the URL.
1515
Reloading the page always brings the user back to the initial scene.
1616

17-
The example also uses the [`StorageService`](https://docs.rs/yew/latest/yew/services/struct.StorageService.html)
17+
The example also uses the [`StorageService`](https://docs.rs/yew-services/latest/yew_services/struct.StorageService.html)
1818
to persist the clients across sessions.
1919

2020
## Improvements

examples/crm/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use add_client::AddClientForm;
22
use serde::{Deserialize, Serialize};
33
use yew::format::Json;
4-
use yew::services::storage::Area;
5-
use yew::services::{DialogService, StorageService};
64
use yew::{html, Component, ComponentLink, Html, ShouldRender};
5+
use yew_services::storage::Area;
6+
use yew_services::{DialogService, StorageService};
77

88
mod add_client;
99

examples/dashboard/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ anyhow = "1"
99
serde = "1"
1010
serde_derive = "1"
1111
yew = { path = "../../packages/yew", features = ["toml"] }
12+
yew-services = { path = "../../packages/yew-services" }

examples/dashboard/src/main.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use anyhow::Error;
22
use serde_derive::{Deserialize, Serialize};
33
use yew::format::{Json, Nothing, Toml};
4-
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
5-
use yew::services::websocket::{WebSocketService, WebSocketStatus, WebSocketTask};
64
use yew::{html, Component, ComponentLink, Html, ShouldRender};
5+
use yew_services::fetch::{FetchService, FetchTask, Request, Response};
6+
use yew_services::websocket::{WebSocketService, WebSocketStatus, WebSocketTask};
77

88
type AsBinary = bool;
99

@@ -72,7 +72,7 @@ impl Model {
7272
}
7373
}
7474

75-
fn fetch_json(&mut self, binary: AsBinary) -> yew::services::fetch::FetchTask {
75+
fn fetch_json(&mut self, binary: AsBinary) -> yew_services::fetch::FetchTask {
7676
let callback = self.link.batch_callback(
7777
move |response: Response<Json<Result<DataFromFile, Error>>>| {
7878
let (meta, Json(data)) = response.into_parts();
@@ -92,7 +92,7 @@ impl Model {
9292
}
9393
}
9494

95-
pub fn fetch_toml(&mut self, binary: AsBinary) -> yew::services::fetch::FetchTask {
95+
pub fn fetch_toml(&mut self, binary: AsBinary) -> yew_services::fetch::FetchTask {
9696
let callback = self.link.batch_callback(
9797
move |response: Response<Toml<Result<DataFromFile, Error>>>| {
9898
let (meta, Toml(data)) = response.into_parts();

examples/file_upload/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ edition = "2018"
77
[dependencies]
88
js-sys = "0.3"
99
yew = { path = "../../packages/yew" }
10+
yew-services = { path = "../../packages/yew-services" }

examples/file_upload/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use yew::services::reader::{File, FileChunk, FileData, ReaderService, ReaderTask};
21
use yew::{html, ChangeData, Component, ComponentLink, Html, ShouldRender};
2+
use yew_services::reader::{File, FileChunk, FileData, ReaderService, ReaderTask};
33

44
type Chunks = bool;
55

examples/futures/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ wasm-bindgen = "0.2"
1010
wasm-bindgen-futures = "0.4"
1111
yew = { path = "../../packages/yew" }
1212
yewtil = { path = "../../packages/yewtil", features = ["future"] }
13+
yew-services = { path = "../../packages/yew-services" }
1314

1415
[dependencies.web-sys]
1516
version = "0.3"

examples/game_of_life/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ log = "0.4"
1414
rand = "0.8"
1515
wasm-logger = "0.2"
1616
yew = { path = "../../packages/yew" }
17+
yew-services = { path = "../../packages/yew-services" }

examples/game_of_life/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use cell::Cellule;
22
use rand::Rng;
33
use std::time::Duration;
4-
use yew::services::interval::{IntervalService, IntervalTask};
54
use yew::{classes, html, Component, ComponentLink, Html, ShouldRender};
5+
use yew_services::interval::{IntervalService, IntervalTask};
66

77
mod cell;
88

examples/inner_html/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2018"
66

77
[dependencies]
88
yew = { path = "../../packages/yew" }
9+
yew-services = { path = "../../packages/yew-services" }
910

1011
[dependencies.web-sys]
1112
version = "0.3"

examples/js_callback/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ edition = "2018"
77
[dependencies]
88
wasm-bindgen = "0.2"
99
yew = { path = "../../packages/yew" }
10+
yew-services = { path = "../../packages/yew-services" }

examples/keyed_list/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ rand = "0.8"
1313
wasm-logger = "0.2"
1414
yew = { path = "../../packages/yew" }
1515
yewtil = { path = "../../packages/yewtil" }
16+
yew-services = { path = "../../packages/yew-services" }

examples/mount_point/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2018"
77
[dependencies]
88
wasm-bindgen = "0.2"
99
yew = { path = "../../packages/yew" }
10+
yew-services = { path = "../../packages/yew-services" }
1011

1112
[dependencies.web-sys]
1213
version = "0.3"

examples/multi_thread/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ log = "0.4"
99
serde = { version = "1.0", features = ["derive"] }
1010
wasm-logger = "0.2"
1111
yew = { path = "../../packages/yew" }
12+
yew-services = { path = "../../packages/yew-services" }

examples/multi_thread/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use serde::{Deserialize, Serialize};
22
use std::time::Duration;
3-
use yew::services::interval::{IntervalService, IntervalTask};
43
use yew::worker::{Agent, AgentLink, Context, HandlerId};
4+
use yew_services::interval::{IntervalService, IntervalTask};
55

66
#[derive(Serialize, Deserialize, Debug)]
77
pub enum Request {

examples/multi_thread/src/job.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use serde::{Deserialize, Serialize};
22
use std::time::Duration;
3-
use yew::services::interval::{IntervalService, IntervalTask};
43
use yew::worker::{Agent, AgentLink, HandlerId, Job};
4+
use yew_services::interval::{IntervalService, IntervalTask};
55

66
#[derive(Serialize, Deserialize, Debug)]
77
pub enum Request {

examples/multi_thread/src/native_worker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use serde::{Deserialize, Serialize};
22
use std::time::Duration;
3-
use yew::services::interval::{IntervalService, IntervalTask};
43
use yew::worker::{Agent, AgentLink, HandlerId, Public};
4+
use yew_services::interval::{IntervalService, IntervalTask};
55

66
#[derive(Serialize, Deserialize, Debug)]
77
pub enum Request {

examples/nested_list/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ edition = "2018"
88
log = "0.4"
99
wasm-logger = "0.2"
1010
yew = { path = "../../packages/yew" }
11+
yew-services = { path = "../../packages/yew-services" }

examples/node_refs/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ edition = "2018"
77
[dependencies]
88
yew = { path = "../../packages/yew" }
99
web-sys = { version = "0.3", features = ["HtmlElement", "HtmlInputElement", "Node"] }
10+
yew-services = { path = "../../packages/yew-services" }

examples/router/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ wasm-logger = "0.2"
1313
yew = { path = "../../packages/yew" }
1414
yew-router = { path = "../../packages/yew-router" }
1515
yewtil = { path = "../../packages/yewtil" }
16+
yew-services = { path = "../../packages/yew-services" }

examples/router/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ Take a look at [`PublicUrlSwitch`](src/switch.rs) for the implementation.
4444
- Home (`/`) should include links to the post list and the author introduction
4545
- Detect sub-path from `--public-url` value passed to Trunk. See: thedodd/trunk#51
4646

47-
[`intervalservice`]: https://docs.rs/yew/latest/yew/services/struct.IntervalService.html
47+
[`intervalservice`]: https://docs.rs/yew-services/latest/yew_services/struct.IntervalService.html
4848
[`yew-router`]: https://docs.rs/yew-router/latest/yew_router/

examples/router/src/components/progress_delay.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use instant::Instant;
22
use std::time::Duration;
3-
use yew::{
4-
prelude::*,
5-
services::interval::{IntervalService, IntervalTask},
6-
};
3+
use yew::prelude::*;
4+
use yew_services::interval::{IntervalService, IntervalTask};
75
use yewtil::NeqAssign;
86

97
const RESOLUTION: u64 = 500;

examples/store/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ edition = "2018"
77
[dependencies]
88
yew = { path = "../../packages/yew" }
99
yewtil = { path = "../../packages/yewtil" }
10+
yew-services = { path = "../../packages/yew-services" }

examples/store/src/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ mod text_input;
55
use agents::posts::{PostId, PostStore, Request};
66
use post::Post;
77
use text_input::TextInput;
8-
use yew::{prelude::*, services::ConsoleService};
8+
use yew::prelude::*;
9+
use yew_services::ConsoleService;
910
use yewtil::store::{Bridgeable, ReadOnly, StoreWrapper};
1011

1112
pub enum Msg {

examples/timer/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ edition = "2018"
77
[dependencies]
88
yew = { path = "../../packages/yew" }
99
js-sys = "0.3"
10+
yew-services = { path = "../../packages/yew-services" }

examples/timer/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ but also makes use of some more advanced [`ConsoleService`] features.
1313

1414
- Apply the concept to something more fun than just a dry technical demonstration
1515

16-
[`timeoutservice`]: https://docs.rs/yew/latest/yew/services/struct.TimeoutService.html
17-
[`intervalservice`]: https://docs.rs/yew/latest/yew/services/struct.IntervalService.html
18-
[`consoleservice`]: https://docs.rs/yew/latest/yew/services/struct.ConsoleService.html
16+
[`timeoutservice`]: https://docs.rs/yew-services/latest/yew_services/struct.TimeoutService.html
17+
[`intervalservice`]: https://docs.rs/yew-services/latest/yew_services/struct.IntervalService.html
18+
[`consoleservice`]: https://docs.rs/yew-services/latest/yew_services/struct.ConsoleService.html

examples/timer/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::time::Duration;
2-
use yew::services::interval::{IntervalService, IntervalTask};
3-
use yew::services::{ConsoleService, Task, TimeoutService};
42
use yew::{html, Callback, Component, ComponentLink, Html, ShouldRender};
3+
use yew_services::interval::{IntervalService, IntervalTask};
4+
use yew_services::{ConsoleService, Task, TimeoutService};
55

66
pub enum Msg {
77
StartTimeout,

examples/todomvc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ strum_macros = "0.20"
1010
serde = "1"
1111
serde_derive = "1"
1212
yew = { path = "../../packages/yew" }
13+
yew-services = { path = "../../packages/yew-services" }

examples/todomvc/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ including: all entries, entered text and chosen filter.
1717
- Use `yew-router` for the hash based routing
1818
- Clean up the code
1919

20-
[`storageservice`]: https://docs.rs/yew/latest/yew/services/struct.StorageService.html
20+
[`storageservice`]: https://docs.rs/yew-services/latest/yew_services/struct.StorageService.html
2121
[`refs`]: https://yew.rs/docs/en/concepts/components/refs/

examples/todomvc/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use state::{Entry, Filter, State};
22
use strum::IntoEnumIterator;
33
use yew::format::Json;
4-
use yew::services::storage::{Area, StorageService};
54
use yew::web_sys::HtmlInputElement as InputElement;
65
use yew::{classes, html, Component, ComponentLink, Html, InputData, NodeRef, ShouldRender};
76
use yew::{events::KeyboardEvent, Classes};
7+
use yew_services::storage::{Area, StorageService};
88

99
mod state;
1010

0 commit comments

Comments
 (0)