Reputation: 10117
I'm creating an user event system using JDK 9 Flow API, so I have a room (which extends the UserSubscriver
class above), it may have many users and each user can offer (dispatch) updates at any time.
public abstract class UserSubscriver implements Flow.Subscriber<Notification> {
private Flow.Subscription subscription;
@Override
public void onSubscribe(final Flow.Subscription subscription) {
this.subscription = subscription;
subscription.request(1);
}
@Override
public void onError(final Throwable throwable) {
// ...
}
@Override
public void onNext(final Notification notification) {
// ...
subscription.request(1);
}
@Override
public void onComplete() {
// How can I know who was the publisher of this?
}
}
User class:
public class User extends SubmissionPublisher<Notification> {
....
public int offer(Notification item) {
return super.offer(item, (sub, msg) -> false);
}
}
On the onUpdate
I can receive any args, so I can receive the publisher of the update, but there are no args on onComplete
.
How can I know who was the publisher of an onComplete
event?
Upvotes: 3
Views: 915