Stay organized with collections
Save and categorize content based on your preferences.
Flow.Subscriber
public
static
interface
Flow.Subscriber
java.util.concurrent.Flow.Subscriber<T>
|
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 Subscription
.
Summary
Public methods |
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
|
onSubscribe(Flow.Subscription subscription)
Method invoked prior to invoking any other Subscriber
methods for the given Subscription.
|
Public methods
onComplete
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.
onError
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.
Parameters |
throwable |
Throwable : the exception |
onNext
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.
Parameters |
item |
T : the item |
onSubscribe
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 |
Flow.Subscription : a new subscription |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# Flow.Subscriber\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \n\nFlow.Subscriber\n===============\n\n\n`\npublic\nstatic\n\n\ninterface\nFlow.Subscriber\n`\n\n\n`\n\n\n`\n\n|-------------------------------------------|\n| java.util.concurrent.Flow.Subscriber\\\u003cT\\\u003e |\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known indirect subclasses [Flow.Processor](/reference/java/util/concurrent/Flow.Processor)\\\u003cT, R\\\u003e |--------------------------------------------------------------------------|-----------------------------------------------------------| | [Flow.Processor](/reference/java/util/concurrent/Flow.Processor)\\\u003cT, R\\\u003e | A component that acts as both a Subscriber and Publisher. | |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA receiver of messages. The methods in this interface are\ninvoked in strict sequential order for each [Subscription](/reference/java/util/concurrent/Flow.Subscription).\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[onComplete](/reference/java/util/concurrent/Flow.Subscriber#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#onError(java.lang.Throwable))`(`[Throwable](/reference/java/lang/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. |\n| ` abstract void` | ` `[onNext](/reference/java/util/concurrent/Flow.Subscriber#onNext(T))`(T item) ` Method invoked with a Subscription's next item. |\n| ` abstract void` | ` `[onSubscribe](/reference/java/util/concurrent/Flow.Subscriber#onSubscribe(java.util.concurrent.Flow.Subscription))`(`[Flow.Subscription](/reference/java/util/concurrent/Flow.Subscription)` subscription) ` Method invoked prior to invoking any other Subscriber methods for the given Subscription. |\n\nPublic methods\n--------------\n\n### onComplete\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void 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\u003cbr /\u003e\n\n### onError\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onError (Throwable throwable)\n```\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\u003cbr /\u003e\n\n| Parameters ||\n|-------------|-----------------------------------|\n| `throwable` | `Throwable`: the exception \u003cbr /\u003e |\n\n### onNext\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onNext (T item)\n```\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\u003cbr /\u003e\n\n| Parameters ||\n|--------|----------------------|\n| `item` | `T`: the item \u003cbr /\u003e |\n\n### onSubscribe\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onSubscribe (Flow.Subscription subscription)\n```\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\u003cbr /\u003e\n\n| Parameters ||\n|----------------|------------------------------------------------|\n| `subscription` | `Flow.Subscription`: a new subscription \u003cbr /\u003e |"]]