Flow.Subscription
Stay organized with collections
Save and categorize content based on your preferences.
Message control linking a Flow.Publisher
and Flow.Subscriber
. Subscribers receive items only when requested,
and may cancel at any time. The methods in this interface are
intended to be invoked only by their Subscribers; usages in
other contexts have undefined effects.
Public Method Summary
abstract
void
|
cancel()
Causes the Subscriber to (eventually) stop receiving
messages.
|
abstract
void
|
request(long n)
Adds the given number n of items to the current
unfulfilled demand for this subscription.
|
Public Methods
public
abstract
void
cancel
()
Causes the Subscriber to (eventually) stop receiving
messages. Implementation is best-effort -- additional
messages may be received after invoking this method.
A cancelled subscription need not ever receive an
onComplete
or onError
signal.
public
abstract
void
request
(long n)
Adds the given number n
of items to the current
unfulfilled demand for this subscription. If n
is
less than or equal to zero, the Subscriber will receive an
onError
signal with an IllegalArgumentException
argument. Otherwise, the
Subscriber will receive up to n
additional onNext
invocations (or fewer if terminated).
Parameters
n |
the increment of demand; a value of Long.MAX_VALUE may be considered as effectively unbounded
|
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.Subscription\u003c/code\u003e manages the flow of messages between a \u003ccode\u003eFlow.Publisher\u003c/code\u003e and a \u003ccode\u003eFlow.Subscriber\u003c/code\u003e, enabling controlled message delivery and cancellation.\u003c/p\u003e\n"],["\u003cp\u003eSubscribers use \u003ccode\u003erequest(long n)\u003c/code\u003e to signal their demand for \u003ccode\u003en\u003c/code\u003e additional messages, while \u003ccode\u003ecancel()\u003c/code\u003e initiates the termination of message delivery.\u003c/p\u003e\n"],["\u003cp\u003eAlthough \u003ccode\u003ecancel()\u003c/code\u003e aims to halt message delivery, it's best-effort and subscribers might still receive some messages afterward, and termination signals like \u003ccode\u003eonComplete\u003c/code\u003e or \u003ccode\u003eonError\u003c/code\u003e are not guaranteed.\u003c/p\u003e\n"],["\u003cp\u003eRequesting a non-positive number of items through \u003ccode\u003erequest\u003c/code\u003e will result in an \u003ccode\u003eonError\u003c/code\u003e signal with an \u003ccode\u003eIllegalArgumentException\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Flow.Subscription\n\npublic static interface **Flow.Subscription** \nMessage control linking a [Flow.Publisher](../../../../reference/java/util/concurrent/Flow.Publisher.html) and [Flow.Subscriber](../../../../reference/java/util/concurrent/Flow.Subscriber.html). Subscribers receive items only when requested,\nand may cancel at any time. The methods in this interface are\nintended to be invoked only by their Subscribers; usages in\nother contexts have undefined effects. \n\n### Public Method Summary\n\n|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [cancel](../../../../reference/java/util/concurrent/Flow.Subscription.html#cancel())() Causes the Subscriber to (eventually) stop receiving messages. |\n| abstract void | [request](../../../../reference/java/util/concurrent/Flow.Subscription.html#request(long))(long n) Adds the given number `n` of items to the current unfulfilled demand for this subscription. |\n\nPublic Methods\n--------------\n\n#### public abstract void\n**cancel**\n()\n\nCauses the Subscriber to (eventually) stop receiving\nmessages. Implementation is best-effort -- additional\nmessages may be received after invoking this method.\nA cancelled subscription need not ever receive an\n`onComplete` or `onError` signal. \n\n#### public abstract void\n**request**\n(long n)\n\nAdds the given number `n` of items to the current\nunfulfilled demand for this subscription. If `n` is\nless than or equal to zero, the Subscriber will receive an\n`onError` signal with an [IllegalArgumentException](../../../../reference/java/lang/IllegalArgumentException.html) argument. Otherwise, the\nSubscriber will receive up to `n` additional `onNext` invocations (or fewer if terminated). \n\n##### Parameters\n\n| n | the increment of demand; a value of `Long.MAX_VALUE` may be considered as effectively unbounded |\n|---|-------------------------------------------------------------------------------------------------|"]]