Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move yew/services to yew-services crate #1693

Merged
merged 12 commits into from
Jan 23, 2021
9 changes: 8 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
# To fix this we just run them on yew but with yew-stdweb's default features enabled.
cd packages/yew
cargo test --doc \
--no-default-features --features "services agent std_web" \
--no-default-features --features "agent std_web" \
--features "doc_test wasm_test yaml msgpack cbor toml"

integration_tests:
Expand Down Expand Up @@ -183,6 +183,13 @@ jobs:
# FIXME: Chrome really doesn't seem to like yew-stdweb
wasm-pack test --firefox --headless -- --features "wasm_test httpbin_test"

- name: Run tests - yew-services
ranile marked this conversation as resolved.
Show resolved Hide resolved
env:
HTTPBIN_URL: "http://localhost:8080"
run: |
cd packages/yew-services
wasm-pack test --firefox --chrome --headless -- --features "wasm_test httpbin_test"

- name: Run tests - yew-functional
run: |
cd packages/yew-functional
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ This release introduces the concept of an `Agent`. Agents are separate activitie
- `Public` agent spawns an agent in a separate thread (it uses [Web Workers API] under the hood).
- Allow setting the whole properties struct of a component with `<Component: with props />`
- `ComponentLink` now has a `send_self` method which allows components to update themselves [[@DenisKolodin], [#365](https://github.com/yewstack/yew/pull/365)]
- All services are re-exported within the `yew::services` module.
- All services are re-exported within the `yew_services` module.
ranile marked this conversation as resolved.
Show resolved Hide resolved
- `html!` macro supports multiple classes in a single string:
`<a class="button is-primary",>`.
- Added `FetchOptions` to allow setting `Credentials` of `fetch` request.
Expand Down
4 changes: 2 additions & 2 deletions docs/concepts/services/fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub type Binary = Result<Vec<u8>, Error>;
Here is what a typical GET request will look like:
```rust
use yew::format::Nothing;
use yew::services::fetch::Request;
use yew_services::fetch::Request;
let get_request = Request::get("https://example.com/api/v1/get/something")
.body(Nothing)
.expect("Could not build that request");
Expand All @@ -36,7 +36,7 @@ Here is what a typical POST request will look like:
```rust
use serde_json::json;
use yew::format::Json;
use yew::services::fetch::Request;
use yew_services::fetch::Request;
let post_request = Request::post("https://example.com/api/v1/post/something")
.header("Content-Type", "application/json")
.body(Json(&json!({"key": "value"})))
Expand Down
1 change: 1 addition & 0 deletions examples/boids/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ getrandom = { version = "0.2", features = ["js"] }
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }
2 changes: 1 addition & 1 deletion examples/boids/src/settings.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};
use yew::format::Json;
use yew::services::storage::{Area, StorageService};
use yew_services::storage::{Area, StorageService};

#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct Settings {
Expand Down
2 changes: 1 addition & 1 deletion examples/boids/src/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::boid::Boid;
use crate::math::Vector2D;
use crate::settings::Settings;
use std::time::Duration;
use yew::services::interval::{IntervalService, IntervalTask};
use yew::{html, Component, ComponentLink, Html, Properties, ShouldRender};
use yew_services::interval::{IntervalService, IntervalTask};

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

Expand Down
1 change: 1 addition & 0 deletions examples/counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ edition = "2018"
[dependencies]
js-sys = "0.3"
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }
2 changes: 1 addition & 1 deletion examples/counter/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use js_sys::Date;
use yew::services::ConsoleService;
use yew::{html, Component, ComponentLink, Html, ShouldRender};
use yew_services::ConsoleService;

pub enum Msg {
Increment,
Expand Down
1 change: 1 addition & 0 deletions examples/crm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ edition = "2018"
serde = "1"
serde_derive = "1"
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }
4 changes: 2 additions & 2 deletions examples/crm/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use add_client::AddClientForm;
use serde::{Deserialize, Serialize};
use yew::format::Json;
use yew::services::storage::Area;
use yew::services::{DialogService, StorageService};
use yew::{html, Component, ComponentLink, Html, ShouldRender};
use yew_services::storage::Area;
use yew_services::{DialogService, StorageService};

mod add_client;

Expand Down
1 change: 1 addition & 0 deletions examples/dashboard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ anyhow = "1"
serde = "1"
serde_derive = "1"
yew = { path = "../../packages/yew", features = ["toml"] }
yew-services = { path = "../../packages/yew-services" }
8 changes: 4 additions & 4 deletions examples/dashboard/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use anyhow::Error;
use serde_derive::{Deserialize, Serialize};
use yew::format::{Json, Nothing, Toml};
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
use yew::services::websocket::{WebSocketService, WebSocketStatus, WebSocketTask};
use yew::{html, Component, ComponentLink, Html, ShouldRender};
use yew_services::fetch::{FetchService, FetchTask, Request, Response};
use yew_services::websocket::{WebSocketService, WebSocketStatus, WebSocketTask};

type AsBinary = bool;

Expand Down Expand Up @@ -72,7 +72,7 @@ impl Model {
}
}

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

pub fn fetch_toml(&mut self, binary: AsBinary) -> yew::services::fetch::FetchTask {
pub fn fetch_toml(&mut self, binary: AsBinary) -> yew_services::fetch::FetchTask {
let callback = self.link.batch_callback(
move |response: Response<Toml<Result<DataFromFile, Error>>>| {
let (meta, Toml(data)) = response.into_parts();
Expand Down
1 change: 1 addition & 0 deletions examples/file_upload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ edition = "2018"
[dependencies]
js-sys = "0.3"
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }
2 changes: 1 addition & 1 deletion examples/file_upload/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use yew::services::reader::{File, FileChunk, FileData, ReaderService, ReaderTask};
use yew::{html, ChangeData, Component, ComponentLink, Html, ShouldRender};
use yew_services::reader::{File, FileChunk, FileData, ReaderService, ReaderTask};

type Chunks = bool;

Expand Down
1 change: 1 addition & 0 deletions examples/futures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
yew = { path = "../../packages/yew" }
yewtil = { path = "../../packages/yewtil", features = ["future"] }
yew-services = { path = "../../packages/yew-services" }

[dependencies.web-sys]
version = "0.3"
Expand Down
1 change: 1 addition & 0 deletions examples/game_of_life/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ log = "0.4"
rand = "0.8"
wasm-logger = "0.2"
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }
2 changes: 1 addition & 1 deletion examples/game_of_life/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cell::Cellule;
use rand::Rng;
use std::time::Duration;
use yew::services::interval::{IntervalService, IntervalTask};
use yew::{classes, html, Component, ComponentLink, Html, ShouldRender};
use yew_services::interval::{IntervalService, IntervalTask};

mod cell;

Expand Down
1 change: 1 addition & 0 deletions examples/inner_html/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2018"

[dependencies]
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }

[dependencies.web-sys]
version = "0.3"
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 @@ -7,3 +7,4 @@ edition = "2018"
[dependencies]
wasm-bindgen = "0.2"
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }
1 change: 1 addition & 0 deletions examples/keyed_list/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ rand = "0.8"
wasm-logger = "0.2"
yew = { path = "../../packages/yew" }
yewtil = { path = "../../packages/yewtil" }
yew-services = { path = "../../packages/yew-services" }
1 change: 1 addition & 0 deletions examples/mount_point/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2018"
[dependencies]
wasm-bindgen = "0.2"
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }

[dependencies.web-sys]
version = "0.3"
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 @@ -9,3 +9,4 @@ log = "0.4"
serde = { version = "1.0", features = ["derive"] }
wasm-logger = "0.2"
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }
2 changes: 1 addition & 1 deletion examples/multi_thread/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use std::time::Duration;
use yew::services::interval::{IntervalService, IntervalTask};
use yew::worker::{Agent, AgentLink, Context, HandlerId};
use yew_services::interval::{IntervalService, IntervalTask};

#[derive(Serialize, Deserialize, Debug)]
pub enum Request {
Expand Down
2 changes: 1 addition & 1 deletion examples/multi_thread/src/job.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use std::time::Duration;
use yew::services::interval::{IntervalService, IntervalTask};
use yew::worker::{Agent, AgentLink, HandlerId, Job};
use yew_services::interval::{IntervalService, IntervalTask};

#[derive(Serialize, Deserialize, Debug)]
pub enum Request {
Expand Down
2 changes: 1 addition & 1 deletion examples/multi_thread/src/native_worker.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use std::time::Duration;
use yew::services::interval::{IntervalService, IntervalTask};
use yew::worker::{Agent, AgentLink, HandlerId, Public};
use yew_services::interval::{IntervalService, IntervalTask};

#[derive(Serialize, Deserialize, Debug)]
pub enum Request {
Expand Down
1 change: 1 addition & 0 deletions examples/nested_list/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ edition = "2018"
log = "0.4"
wasm-logger = "0.2"
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }
1 change: 1 addition & 0 deletions examples/node_refs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ edition = "2018"
[dependencies]
yew = { path = "../../packages/yew" }
web-sys = { version = "0.3", features = ["HtmlElement", "HtmlInputElement", "Node"] }
yew-services = { path = "../../packages/yew-services" }
1 change: 1 addition & 0 deletions examples/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ wasm-logger = "0.2"
yew = { path = "../../packages/yew" }
yew-router = { path = "../../packages/yew-router" }
yewtil = { path = "../../packages/yewtil" }
yew-services = { path = "../../packages/yew-services" }
6 changes: 2 additions & 4 deletions examples/router/src/components/progress_delay.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use instant::Instant;
use std::time::Duration;
use yew::{
prelude::*,
services::interval::{IntervalService, IntervalTask},
};
use yew::prelude::*;
use yew_services::interval::{IntervalService, IntervalTask};
use yewtil::NeqAssign;

const RESOLUTION: u64 = 500;
Expand Down
1 change: 1 addition & 0 deletions examples/store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ edition = "2018"
[dependencies]
yew = { path = "../../packages/yew" }
yewtil = { path = "../../packages/yewtil" }
yew-services = { path = "../../packages/yew-services" }
3 changes: 2 additions & 1 deletion examples/store/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ mod text_input;
use agents::posts::{PostId, PostStore, Request};
use post::Post;
use text_input::TextInput;
use yew::{prelude::*, services::ConsoleService};
use yew::prelude::*;
use yew_services::ConsoleService;
use yewtil::store::{Bridgeable, ReadOnly, StoreWrapper};

pub enum Msg {
Expand Down
1 change: 1 addition & 0 deletions examples/timer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ edition = "2018"
[dependencies]
yew = { path = "../../packages/yew" }
js-sys = "0.3"
yew-services = { path = "../../packages/yew-services" }
4 changes: 2 additions & 2 deletions examples/timer/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;
use yew::services::interval::{IntervalService, IntervalTask};
use yew::services::{ConsoleService, Task, TimeoutService};
use yew::{html, Callback, Component, ComponentLink, Html, ShouldRender};
use yew_services::interval::{IntervalService, IntervalTask};
use yew_services::{ConsoleService, Task, TimeoutService};

pub enum Msg {
StartTimeout,
Expand Down
1 change: 1 addition & 0 deletions examples/todomvc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ strum_macros = "0.20"
serde = "1"
serde_derive = "1"
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }
2 changes: 1 addition & 1 deletion examples/todomvc/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use state::{Entry, Filter, State};
use strum::IntoEnumIterator;
use yew::format::Json;
use yew::services::storage::{Area, StorageService};
use yew::web_sys::HtmlInputElement as InputElement;
use yew::{classes, html, Component, ComponentLink, Html, InputData, NodeRef, ShouldRender};
use yew::{events::KeyboardEvent, Classes};
use yew_services::storage::{Area, StorageService};

mod state;

Expand Down
1 change: 1 addition & 0 deletions examples/two_apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ edition = "2018"

[dependencies]
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }
1 change: 1 addition & 0 deletions examples/webgl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2018"
js-sys = "0.3"
wasm-bindgen = "0.2"
yew = { path = "../../packages/yew" }
yew-services = { path = "../../packages/yew-services" }

[dependencies.web-sys]
version = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions examples/webgl/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use wasm_bindgen::JsCast;
use web_sys::{HtmlCanvasElement, WebGlRenderingContext as GL};
use yew::services::render::RenderTask;
use yew::services::RenderService;
use yew::{html, Component, ComponentLink, Html, NodeRef, ShouldRender};
use yew_services::render::RenderTask;
use yew_services::RenderService;

pub enum Msg {
Render(f64),
Expand Down
1 change: 1 addition & 0 deletions packages/yew-functional/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ description = "A framework for making client-side single-page apps"
wasm-bindgen-test = "0.3.9"
web-sys = "0.3.36"
yew = { path = "../yew" }
yew-services = { path = "../yew-services" }

[dependencies]
yew = { path = "../yew" }
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-functional/tests/use_context_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn use_context_scoping_works() {

fn run(_props: &Self::TProps) -> Html {
if use_context::<ExampleContext>().is_some() {
yew::services::ConsoleService::log(&format!(
yew_services::ConsoleService::log(&format!(
"Context should be None here, but was {:?}!",
use_context::<ExampleContext>().unwrap()
));
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ web_sys = [
]

[dependencies]
yew = { version = "0.17.0", path = "../yew", features = ["services", "agent"], default-features= false, optional = true }
yew = { version = "0.17.0", path = "../yew", features = ["agent"], default-features= false, optional = true }
yew-router-macro = { version = "0.14.0", path = "../yew-router-macro" }
yew-router-route-parser = { version = "0.14.0", path = "../yew-router-route-parser" }

Expand Down
Loading