Skip to content

Commit 1a956be

Browse files
committed
add an example for consume http response
1 parent e00fd9b commit 1a956be

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

examples/typed.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,17 @@ fn send_request(mut ev_request: EventWriter<TypedRequest<IpInfo>>) {
2727
);
2828
}
2929

30-
fn handle_response(mut ev_response: EventReader<TypedResponse<IpInfo>>) {
31-
for response in ev_response.read() {
32-
println!("ip: {}", response.ip);
30+
// fn handle_response(mut ev_response: EventReader<TypedResponse<IpInfo>>) {
31+
// for response in ev_response.read() {
32+
// println!("ip: {}", response.ip);
33+
// }
34+
// }
35+
36+
/// consume TypedResponse<IpInfo> events
37+
fn handle_response(mut events: ResMut<Events<TypedResponse<IpInfo>>>) {
38+
for response in events.drain() {
39+
let response: IpInfo = response.into_inner();
40+
println!("ip info: {:?}", response);
3341
}
3442
}
3543

0 commit comments

Comments
 (0)