0

if I have a JavaFX property and I create an event stream from this property:

EventStreams.nonNullValuesOf(node.boundsInParentProperty())

Is there a possibility to set the source (in this case the "node") at creation time or to get this object later in a subscription?

For example:

EventStream<...> stream = EventStreams.nonNullValuesOf(node.boundsInParentProperty());

...
stream.subscribe((node, bounds) -> ...);

or at creation time:

EventStream<...> stream = EventStreams.valueAndSource(node.boundsInParentProperty(), node);
schlegel11
  • 363
  • 4
  • 8

1 Answers1

1

OK I got what I want with:

EventStreams.nonNullValuesOf(node.boundsInParentProperty()).map(bounds -> ...)

My problem was that I have a list with N node objects which are reachable at iteration time. Solved my problem like:

EventStream<Tuple2<Node, Bounds>> eventStream = nodes.stream().
map(node -> EventStreams.nonNullValuesOf(node.boundsInParentProperty()).map(bounds -> Tuples.t(node, bounds))).
reduce((es, esAccu) -> EventStreams.merge(es, esAccu)).
orElse(EventStreams.never());
schlegel11
  • 363
  • 4
  • 8