Skip to content

Commit c674841

Browse files
committed
update Changelog and READMe
1 parent b111085 commit c674841

File tree

3 files changed

+32
-20
lines changed

3 files changed

+32
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [0.5.0] - 2024-02-20
4+
5+
- now it's use event to send request and handle response
6+
37
## [0.4.0] - 2024-02-19
48

59
- bump bevy version to 0.13.0

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "bevy_http_client"
33
description = "A simple HTTP client for Bevy"
4-
version = "0.4.0"
4+
version = "0.5.0"
55
edition = "2021"
66
readme = "README.md"
77
repository = "https://github.com/foxzool/bevy_http_client"
88
authors = ["FoxZoOL <[email protected]>"]
99
license = "MIT OR Apache-2.0"
10-
keywords = ["bevy", "http", "plugin"]
10+
keywords = ["bevy", "http", "plugin", "wasm"]
1111

1212
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1313

README.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,54 @@
55
[![Documentation](https://docs.rs/bevy_http_client/badge.svg)](https://docs.rs/bevy_http_client)
66
[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/Seldom-SE/seldom_pixel#license)
77

8-
A simple HTTP client Bevy Plugin for both native and WASM.
8+
A simple HTTP client Bevy Plugin for both native and WASM.
99

1010
## Example
1111

1212
```rust
1313
use bevy::{prelude::*, time::common_conditions::on_timer};
1414
use bevy_http_client::prelude::*;
15+
use serde::Deserialize;
16+
17+
#[derive(Debug, Clone, Deserialize, Default)]
18+
pub struct IpInfo {
19+
pub ip: String,
20+
}
1521

1622
fn main() {
17-
App::new()
18-
.add_plugins((MinimalPlugins, HttpClientPlugin))
23+
let mut app = App::new();
24+
app.add_plugins((MinimalPlugins, HttpClientPlugin))
1925
.add_systems(Update, handle_response)
2026
.add_systems(
2127
Update,
2228
send_request.run_if(on_timer(std::time::Duration::from_secs(1))),
23-
)
24-
.run()
29+
);
30+
app.register_request_type::<IpInfo>();
31+
app.run();
2532
}
2633

27-
fn send_request(mut commands: Commands) {
28-
let req = ehttp::Request::get("https://api.ipify.org?format=json");
29-
commands.spawn(HttpRequest(req));
34+
fn send_request(mut ev_request: EventWriter<TypedRequest<IpInfo>>) {
35+
ev_request.send(
36+
HttpClient::new()
37+
.get("https://api.ipify.org?format=json")
38+
.with_type::<IpInfo>(),
39+
);
3040
}
3141

32-
fn handle_response(mut commands: Commands, responses: Query<(Entity, &HttpResponse)>) {
33-
for (entity, response) in responses.iter() {
34-
println!("response: {:?}", response.text());
35-
commands.entity(entity).despawn_recursive();
42+
fn handle_response(mut ev_response: EventReader<TypedResponse<IpInfo>>) {
43+
for response in ev_response.read() {
44+
println!("ip: {}", response.ip);
3645
}
3746
}
3847
```
3948

40-
4149
## Supported Versions
4250

43-
| bevy | bevy_cronjob |
44-
|------|--------------|
45-
| 0.13 | 0.4 |
46-
| 0.12 | 0.3 |
47-
| 0.11 | 0.1 |
51+
| bevy | bevy_http_client |
52+
|------|------------------|
53+
| 0.13 | 0.4, 0,5 |
54+
| 0.12 | 0.3 |
55+
| 0.11 | 0.1 |
4856

4957
## License
5058

0 commit comments

Comments
 (0)