Flow.Subscriber
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
Flow.Processor<T, R> |
A component that acts as both a Subscriber and Publisher. |
|
A receiver of messages. The methods in this interface are
invoked in strict sequential order for each Flow.Subscription
.
Public Method Summary
abstract
void
|
onComplete()
Method invoked when it is known that no additional
Subscriber method invocations will occur for a Subscription
that is not already terminated by error, after which no
other Subscriber methods are invoked by the Subscription.
|
abstract
void
|
onError( Throwable throwable)
Method invoked upon an unrecoverable error encountered by a
Publisher or Subscription, after which no other Subscriber
methods are invoked by the Subscription.
|
abstract
void
|
onNext(T item)
Method invoked with a Subscription's next item.
|
abstract
void
|
|
Public Methods
public
abstract
void
onComplete
()
Method invoked when it is known that no additional
Subscriber method invocations will occur for a Subscription
that is not already terminated by error, after which no
other Subscriber methods are invoked by the Subscription.
If this method throws an exception, resulting behavior is
undefined.
public
abstract
void
onError
(Throwable throwable)
Method invoked upon an unrecoverable error encountered by a
Publisher or Subscription, after which no other Subscriber
methods are invoked by the Subscription. If this method
itself throws an exception, resulting behavior is
undefined.
public
abstract
void
onNext
(T item)
Method invoked with a Subscription's next item. If this
method throws an exception, resulting behavior is not
guaranteed, but may cause the Subscription to be cancelled.
public
abstract
void
onSubscribe
(Flow.Subscription subscription)
Method invoked prior to invoking any other Subscriber
methods for the given Subscription. If this method throws
an exception, resulting behavior is not guaranteed, but may
cause the Subscription not to be established or to be cancelled.
Typically, implementations of this method invoke subscription.request
to enable receiving items.
Parameters
subscription |
a new subscription
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eFlow.Subscriber\u003c/code\u003e is an interface defining a receiver of messages in a reactive stream.\u003c/p\u003e\n"],["\u003cp\u003eIt has four key methods: \u003ccode\u003eonSubscribe\u003c/code\u003e, \u003ccode\u003eonNext\u003c/code\u003e, \u003ccode\u003eonError\u003c/code\u003e, and \u003ccode\u003eonComplete\u003c/code\u003e, invoked sequentially for each subscription.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eonSubscribe\u003c/code\u003e is called first to establish the subscription, enabling the subscriber to request items.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eonNext\u003c/code\u003e delivers the next item in the stream, while \u003ccode\u003eonError\u003c/code\u003e signals an unrecoverable error, halting further delivery.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eonComplete\u003c/code\u003e indicates the successful completion of the stream, signifying no more items will be delivered.\u003c/p\u003e\n"]]],[],null,["# Flow.Subscriber\n\npublic static interface **Flow.Subscriber** \n\n|---|---|---|\n| Known Indirect Subclasses [Flow.Processor](../../../../reference/java/util/concurrent/Flow.Processor.html)\\\u003cT, R\\\u003e |------------------------------------------------------------------------------------------|-----------------------------------------------------------| | [Flow.Processor](../../../../reference/java/util/concurrent/Flow.Processor.html)\\\u003cT, R\\\u003e | A component that acts as both a Subscriber and Publisher. | |||\n\nA receiver of messages. The methods in this interface are\ninvoked in strict sequential order for each [Flow.Subscription](../../../../reference/java/util/concurrent/Flow.Subscription.html). \n\n### Public Method Summary\n\n|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [onComplete](../../../../reference/java/util/concurrent/Flow.Subscriber.html#onComplete())() Method invoked when it is known that no additional Subscriber method invocations will occur for a Subscription that is not already terminated by error, after which no other Subscriber methods are invoked by the Subscription. |\n| abstract void | [onError](../../../../reference/java/util/concurrent/Flow.Subscriber.html#onError(java.lang.Throwable))([Throwable](../../../../reference/java/lang/Throwable.html) throwable) Method invoked upon an unrecoverable error encountered by a Publisher or Subscription, after which no other Subscriber methods are invoked by the Subscription. |\n| abstract void | [onNext](../../../../reference/java/util/concurrent/Flow.Subscriber.html#onNext(T))(T item) Method invoked with a Subscription's next item. |\n| abstract void | [onSubscribe](../../../../reference/java/util/concurrent/Flow.Subscriber.html#onSubscribe(java.util.concurrent.Flow.Subscription))([Flow.Subscription](../../../../reference/java/util/concurrent/Flow.Subscription.html) subscription) Method invoked prior to invoking any other Subscriber methods for the given Subscription. |\n\nPublic Methods\n--------------\n\n#### public abstract void\n**onComplete**\n()\n\nMethod invoked when it is known that no additional\nSubscriber method invocations will occur for a Subscription\nthat is not already terminated by error, after which no\nother Subscriber methods are invoked by the Subscription.\nIf this method throws an exception, resulting behavior is\nundefined. \n\n#### public abstract void\n**onError**\n([Throwable](../../../../reference/java/lang/Throwable.html) throwable)\n\nMethod invoked upon an unrecoverable error encountered by a\nPublisher or Subscription, after which no other Subscriber\nmethods are invoked by the Subscription. If this method\nitself throws an exception, resulting behavior is\nundefined. \n\n##### Parameters\n\n| throwable | the exception |\n|-----------|---------------|\n\n#### public abstract void\n**onNext**\n(T item)\n\nMethod invoked with a Subscription's next item. If this\nmethod throws an exception, resulting behavior is not\nguaranteed, but may cause the Subscription to be cancelled. \n\n##### Parameters\n\n| item | the item |\n|------|----------|\n\n#### public abstract void\n**onSubscribe**\n([Flow.Subscription](../../../../reference/java/util/concurrent/Flow.Subscription.html) subscription)\n\nMethod invoked prior to invoking any other Subscriber\nmethods for the given Subscription. If this method throws\nan exception, resulting behavior is not guaranteed, but may\ncause the Subscription not to be established or to be cancelled.\n\nTypically, implementations of this method invoke `subscription.request` to enable receiving items. \n\n##### Parameters\n\n| subscription | a new subscription |\n|--------------|--------------------|"]]