Class Subscriptions

java.lang.Object
rx.subscriptions.Subscriptions

public final class Subscriptions extends Object
Helper methods and utilities for creating and working with Subscription objects
  • Field Details

  • Constructor Details

    • Subscriptions

      private Subscriptions()
  • Method Details

    • empty

      public static Subscription empty()
      Returns a Subscription to which unsubscribe does nothing except to change isUnsubscribed to true. It's stateful and isUnsubscribed indicates if unsubscribe is called, which is different from unsubscribed().
      
       Subscription empty = Subscriptions.empty();
       System.out.println(empty.isUnsubscribed()); // false
       empty.unsubscribe();
       System.out.println(empty.isUnsubscribed()); // true
       
      Returns:
      a Subscription to which unsubscribe does nothing except to change isUnsubscribed to true
    • unsubscribed

      public static Subscription unsubscribed()
      Returns a Subscription to which unsubscribe does nothing, as it is already unsubscribed. Its isUnsubscribed always returns true, which is different from empty().
      
       Subscription unsubscribed = Subscriptions.unsubscribed();
       System.out.println(unsubscribed.isUnsubscribed()); // true
       
      Returns:
      a Subscription to which unsubscribe does nothing, as it is already unsubscribed
      Since:
      1.1.0
    • create

      public static Subscription create(Action0 unsubscribe)
      Creates and returns a Subscription that invokes the given Action0 when unsubscribed.
      Parameters:
      unsubscribe - Action to invoke on unsubscribe.
      Returns:
      Subscription
    • from

      public static Subscription from(Future<?> f)
      Converts a Future into a Subscription and cancels it when unsubscribed.
      Parameters:
      f - the Future to convert
      Returns:
      a Subscription that wraps f
    • from

      public static CompositeSubscription from(Subscription... subscriptions)
      Converts a set of Subscriptions into a CompositeSubscription that groups the multiple Subscriptions together and unsubscribes from all of them together.
      Parameters:
      subscriptions - the Subscriptions to group together
      Returns:
      a CompositeSubscription representing the subscriptions set