响应式应用设计原型ReactiveLab.zip 时间:2022-08-07 21:17:27 【文件属性】: 文件名称:响应式应用设计原型ReactiveLab.zip 文件大小:348KB 文件格式:ZIP 更新时间:2022-08-07 21:17:27 开源项目 ReactiveLab 是响应式应用设计的试验和原型。代码示例: return new UserCommand(userId).observe().flatMap(user -> { Observable> catalog = new PersonalizedCatalogCommand(user).observe() .flatMap(catalogList -> { return catalogList.videos().> flatMap(video -> { Observable bookmark = new BookmarkCommand(video).observe(); Observable rating = new RatingsCommand(video).observe(); Observable<VideoMetadata> metadata = new VideoMetadataCommand(video).observe(); return Observable.zip(bookmark, rating, metadata, (b, r, m) -> { return combineVideoData(video, b, r, m); }); }); }); Observable> social = new SocialCommand(user).observe().map(s -> { return s.getDataAsMap(); }); return Observable.merge(catalog, social); }).flatMap(data -> { return response.writeAndFlush(new ServerSentEvent("", "data", SimpleJson.mapToJson(data)), EdgeServer.SSE_TRANSFORMER); }); 标签:ReactiveLab 立即下载