本文主要是介绍RxJava zip 使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
间隔发送:
String[] codes = irCodeStr.split("\\|");Observable<String> codesDate = Observable.fromArray(codes);Observable<Long> intervalDate = Observable.interval(interval, TimeUnit.MILLISECONDS);Observable.zip(codesDate, intervalDate, (s, aLong) -> s).subscribeOn(Schedulers.io()).observeOn(Schedulers.computation()).subscribe(s -> sendIRInner(freq, irManager, s));
合并两条网络数据:
Observable<List<MainPage.News>> loadNews = ApiManager.displayService.getRecommendNewsList(Hardware.current(context).getName(), true);Observable<List<Video.ShortVideo>> loadShortVideo = ApiManager.displayService.recommendShortVideo();Disposable disposable = Observable.zip(loadNews, loadShortVideo, (news, shortVideos) -> {HomeDataContainer container = new HomeDataContainer();container.recommendNewsList = news;container.recommendShortVideoList = shortVideos;return container;
这篇关于RxJava zip 使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!