RACDisposable.h 988 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // RACDisposable.h
  3. // ReactiveObjC
  4. //
  5. // Created by Josh Abernathy on 3/16/12.
  6. // Copyright (c) 2012 GitHub, Inc. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. @class RACScopedDisposable;
  10. NS_ASSUME_NONNULL_BEGIN
  11. /// A disposable encapsulates the work necessary to tear down and cleanup a
  12. /// subscription.
  13. @interface RACDisposable : NSObject
  14. /// Whether the receiver has been disposed.
  15. ///
  16. /// Use of this property is discouraged, since it may be set to `YES`
  17. /// concurrently at any time.
  18. ///
  19. /// This property is not KVO-compliant.
  20. @property (atomic, assign, getter = isDisposed, readonly) BOOL disposed;
  21. + (instancetype)disposableWithBlock:(void (^)(void))block;
  22. /// Performs the disposal work. Can be called multiple times, though subsequent
  23. /// calls won't do anything.
  24. - (void)dispose;
  25. /// Returns a new disposable which will dispose of this disposable when it gets
  26. /// dealloc'd.
  27. - (RACScopedDisposable *)asScopedDisposable;
  28. @end
  29. NS_ASSUME_NONNULL_END