Created
July 17, 2020 04:10
-
-
Save PatrickGopher/95617d40ce82ef8ef104c01aa619ffd9 to your computer and use it in GitHub Desktop.
java async Subscriber
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NormalSubscriber implements Flow.Subscriber<Long> { | |
private Flow.Subscription subscription; | |
private String name = "NormalSubscriber"; | |
public NormalSubscriber(String name) { | |
this.name = name; | |
} | |
public String getName() { | |
return name; | |
} | |
@Override | |
public void onSubscribe(Flow.Subscription subscription) { | |
this.subscription = subscription; | |
subscription.request(1); | |
} | |
@Override | |
public void onNext(Long item) { | |
System.out.printf("odd number: %d", item); | |
} | |
@Override | |
public void onError(Throwable t) { | |
System.out.printf("err:", t.getMessage()); | |
} | |
@Override | |
public void onComplete() { | |
System.out.printf("odd number check complete"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment