RACCompoundDisposable.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // RACCompoundDisposable.h
  3. // ReactiveObjC
  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. NS_ASSUME_NONNULL_BEGIN
  10. /// A disposable of disposables. When it is disposed, it disposes of all its
  11. /// contained disposables.
  12. ///
  13. /// If -addDisposable: is called after the compound disposable has been disposed
  14. /// of, the given disposable is immediately disposed. This allows a compound
  15. /// disposable to act as a stand-in for a disposable that will be delivered
  16. /// asynchronously.
  17. @interface RACCompoundDisposable : RACDisposable
  18. /// Creates and returns a new compound disposable.
  19. + (instancetype)compoundDisposable;
  20. /// Creates and returns a new compound disposable containing the given
  21. /// disposables.
  22. + (instancetype)compoundDisposableWithDisposables:(nullable NSArray *)disposables;
  23. /// Adds the given disposable. If the receiving disposable has already been
  24. /// disposed of, the given disposable is disposed immediately.
  25. ///
  26. /// This method is thread-safe.
  27. ///
  28. /// disposable - The disposable to add. This may be nil, in which case nothing
  29. /// happens.
  30. - (void)addDisposable:(nullable RACDisposable *)disposable;
  31. /// Removes the specified disposable from the compound disposable (regardless of
  32. /// its disposed status), or does nothing if it's not in the compound disposable.
  33. ///
  34. /// This is mainly useful for limiting the memory usage of the compound
  35. /// disposable for long-running operations.
  36. ///
  37. /// This method is thread-safe.
  38. ///
  39. /// disposable - The disposable to remove. This argument may be nil (to make the
  40. /// use of weak references easier).
  41. - (void)removeDisposable:(nullable RACDisposable *)disposable;
  42. @end
  43. NS_ASSUME_NONNULL_END