davidmoten / rxjava-file

RxJava observables for files including NIO events
Apache License 2.0
82 stars 17 forks source link

Existing lines are not emitted until the file is updated #10

Open lbovet opened 8 years ago

lbovet commented 8 years ago

The existing lines are emitted only when the file changes. This is not like tail(1) which dumps directly the current content.

Is there a way to achieve this or is there a missing flag?

Currently, I worked around with:

    FileObservable.tailer()
            .file(file)
            .tailText()
            .startWith(Observable.defer(() -> {
                try {
                    return Observable.from(Files.readAllLines(Paths.get(file)));
                } catch (IOException e) {
                    return Observable.error(e);
                }
            })

(Note: I defer in order to be sure that I do not miss lines)

lbovet commented 8 years ago

Well, I found the bug, this is a minor thing. It happens only when using the builder. I'll submit a PR asap.

davidmoten commented 8 years ago

Thank you very much for this @lbovet! I'll review soon.

spencerwi commented 8 years ago

Any news on this? Seems like a pretty small change to review with a potentially-big impact.