Class RefCountSubscription

  • All Implemented Interfaces:
    Subscription

    public final class RefCountSubscription
    extends java.lang.Object
    implements Subscription
    Keeps track of the sub-subscriptions and unsubscribes the underlying subscription once all sub-subscriptions have unsubscribed.
    • Constructor Detail

      • RefCountSubscription

        public RefCountSubscription​(Subscription s)
        Creates a RefCountSubscription by wrapping the given non-null Subscription.
        Parameters:
        s - the Subscription to wrap
        Throws:
        java.lang.IllegalArgumentException - if s is null
    • Method Detail

      • get

        public Subscription get()
        Returns a new sub-subscription
        Returns:
        a new sub-subscription.
      • isUnsubscribed

        public boolean isUnsubscribed()
        Description copied from interface: Subscription
        Indicates whether this Subscription is currently unsubscribed.
        Specified by:
        isUnsubscribed in interface Subscription
        Returns:
        true if this Subscription is currently unsubscribed, false otherwise
      • unsubscribe

        public void unsubscribe()
        Description copied from interface: Subscription
        Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.

        This allows unregistering an Subscriber before it has finished receiving all events (i.e. before onCompleted is called).

        Specified by:
        unsubscribe in interface Subscription
      • unsubscribeAChild

        void unsubscribeAChild()