TomasMikula/ReactFX — pull request #7 by iSerge (2014-07-06 19:04:48+00:00)
Title: Fixed initialisation order of subscribers and error handlers

Hi!
Tried to use your reactive library in my GUI project and stumbled upon scenario which produce inconsistent stream behaviour. For example this code produces an empty stream:

SimpleIntegerProperty intProperty = new SimpleIntegerProperty(-1);
List emitted = new LinkedList<>();
List errors = new LinkedList<>();

EventStreams.valuesOf(intProperty)
.map(i -> {
if (i.intValue() < 0) {
throw new IllegalArgumentException("Accepting only positive numbers");
}
return String.valueOf(i);
})
.handleErrors(errors::add)
.subscribe(emitted::add);

The problem is lazy subscription mechanism plus property observer generate first event before stream pipe is properly initialised. My changes fixing this problem.