I have a collection of objects, call them obj
. They have an act()
method. The act()
method will eventually cause the event()
observable on o
to call onComplete
.
What is a good way to chain these?
That is, call o.act()
, wait for o.event().onComplete
and then call the next o2.act()
, and so on for indefinite number of o
in collection.
So the signature is like so:
public class Item {
final protected PublishSubject<Object> event = PublishSubject.create();
public Observable<ReturnType> event() {
return event;
}
public void act() {
// do a bunch of stuff
event.onComplete();
}
}
And then in the consuming code:
Collection<Item> items...
foreach item in items
item.act -> await item.event().onComplete() -> call next item.act() -> so on