RACDisposable.h 941 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // RACDisposable.h
  3. // ReactiveCocoa
  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. /// A disposable encapsulates the work necessary to tear down and cleanup a
  11. /// subscription.
  12. @interface RACDisposable : NSObject
  13. /// Whether the receiver has been disposed.
  14. ///
  15. /// Use of this property is discouraged, since it may be set to `YES`
  16. /// concurrently at any time.
  17. ///
  18. /// This property is not KVO-compliant.
  19. @property (atomic, assign, getter = isDisposed, readonly) BOOL disposed;
  20. + (instancetype)disposableWithBlock:(void (^)(void))block;
  21. /// Performs the disposal work. Can be called multiple times, though subsequent
  22. /// calls won't do anything.
  23. - (void)dispose;
  24. /// Returns a new disposable which will dispose of this disposable when it gets
  25. /// dealloc'd.
  26. - (RACScopedDisposable *)asScopedDisposable;
  27. @end