6 Eylül 2019 Cuma

Java 9 Flow.Subscriber Arayüzü

Giriş
Açıklaması şöyle.
Subscribes to publishers (usually only one) to receive items (via method onNext(T)), error messages (onError(Throwable)), or a signal that no more items are to be expected (onComplete()). Before any of those things happen, though, the publisher calls onSubscription(Subscription).
onComplete metodu
Örnek ver.

onError metodu
Örnek ver.

onNext metodu
Örnek ver.

onSubscribe metodu
Abone olur olmaz yeni veriyi istemek gerekir.
Örnek
Şöyle yaparız.
@Override
public void onSubscribe(Flow.Subscription subscription) {
  this.subscription = subscription;
  this.subscription.request(1);
}


Hiç yorum yok:

Yorum Gönder