RxJava文件和运算符链接 [英] RxJava-file and operator chaining

查看:108
本文介绍了RxJava文件和运算符链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 RxJava文件:

    File file = new File(".\\server.log");
    Observable<String> newLines =
            FileObservable.tailer()
                    .file(file)
                    .startPosition(file.length())
                    .sampleTimeMs(1000)
                    .chunkSize(8192)
                    .utf8()
                    .tailText();

    newLines.subscribe(System.out::println);

,并且按预期方式工作. 但是,一旦我尝试链接更多的运营商,我就会遇到问题.例如,更改为

and it works as expected. But as soon as I try to chain some more operators, I get problems. For instance, changing to

  newLines.filter(LogfileWatcher::error).subscribe(System.out::println);

(其中error()是一个简单的函数String -> Boolean)仅在文件的第一个追加之后才获得输出,而后续的则不输出. 使用window()或其他几种运算符时,也会出现类似的问题.

(where error() is a simple function String -> Boolean) I get output only after the first append to the file, but not the subsequent ones. Similar problems appear when using window() or several other operators.

我在做什么错了?

推荐答案

必须在 rxjava-file 中修复反压支持,并且报告您的测试用例自 rxjava-文件 0.3.3放在Maven Central上.

Backpressure support had to be fixed in rxjava-file and your test case is reported to be working as of rxjava-file 0.3.3 on Maven Central.

这篇关于RxJava文件和运算符链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆