I started using Project Reactor recently and I can't work out how to work with nested streams.
(我最近开始使用Project Reactor,但无法弄清楚如何使用嵌套流。)
I want to update data of outer Mono with some data of inner Mono. (我想用内部Mono的一些数据更新外部Mono的数据。)
@GetMapping("/search")
public Mono<Github> combineGithubData() {
WebClient client = WebClient.create("https://api.github.com");
Mono<Github> data = client.get().uri(URI.create("https://api.github.com/users/autocorrectoff")).retrieve().bodyToMono(Github.class);
data = data.map(s -> {
client.get().uri(URI.create("https://api.github.com/users/Kukilej")).retrieve().bodyToMono(Github.class).map(m -> {
s.setXXX(m.getName());
return m;
});
return s;
});
return data;
}
The field XXX is always returned as null, although I have set it to a value from inner Mono.
(尽管我已将其设置为内部Mono的值,但XXX字段始终返回null。)
I'm pretty sure this would work in RxJs. (我很确定这可以在RxJ中使用。)
How do I make this work with Project Reactor? (如何使用Project Reactor进行这项工作?)
edit: the code of the Github class
(编辑:Github类的代码)
import lombok.*;
@Getter @Setter
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class Github {
private String login;
private int id;
private String node_id;
private String avatar_url;
private String gravatar_id;
private String url;
private String html_url;
private String followers_url;
private String following_url;
private String gists_url;
private String starred_url;
private String subscriptions_url;
private String organizations_url;
private String repos_url;
private String events_url;
private String received_events_url;
private String type;
private boolean site_admin;
private String name;
private String company;
private String blog;
private String location;
private String email;
private String hireable;
private String bio;
private int public_repos;
private int public_gists;
private int followers;
private int following;
private String created_at;
private String updated_at;
private String XXX;
}
ask by ape_face translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…