RACCompoundDisposable.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // RACCompoundDisposable.h
  3. // ReactiveCocoa
  4. //
  5. // Created by Josh Abernathy on 11/30/12.
  6. // Copyright (c) 2012 GitHub, Inc. All rights reserved.
  7. //
  8. #import "RACDisposable.h"
  9. /// A disposable of disposables. When it is disposed, it disposes of all its
  10. /// contained disposables.
  11. ///
  12. /// If -addDisposable: is called after the compound disposable has been disposed
  13. /// of, the given disposable is immediately disposed. This allows a compound
  14. /// disposable to act as a stand-in for a disposable that will be delivered
  15. /// asynchronously.
  16. @interface RACCompoundDisposable : RACDisposable
  17. /// Creates and returns a new compound disposable.
  18. + (instancetype)compoundDisposable;
  19. /// Creates and returns a new compound disposable containing the given
  20. /// disposables.
  21. + (instancetype)compoundDisposableWithDisposables:(NSArray *)disposables;
  22. /// Adds the given disposable. If the receiving disposable has already been
  23. /// disposed of, the given disposable is disposed immediately.
  24. ///
  25. /// This method is thread-safe.
  26. ///
  27. /// disposable - The disposable to add. This may be nil, in which case nothing
  28. /// happens.
  29. - (void)addDisposable:(RACDisposable *)disposable;
  30. /// Removes the specified disposable from the compound disposable (regardless of
  31. /// its disposed status), or does nothing if it's not in the compound disposable.
  32. ///
  33. /// This is mainly useful for limiting the memory usage of the compound
  34. /// disposable for long-running operations.
  35. ///
  36. /// This method is thread-safe.
  37. ///
  38. /// disposable - The disposable to remove. This argument may be nil (to make the
  39. /// use of weak references easier).
  40. - (void)removeDisposable:(RACDisposable *)disposable;
  41. @end