https://github.com/ryuheechul/racautodisposer
Dispose RACSubscriptions with an easy way
https://github.com/ryuheechul/racautodisposer
Last synced: 10 months ago
JSON representation
Dispose RACSubscriptions with an easy way
- Host: GitHub
- URL: https://github.com/ryuheechul/racautodisposer
- Owner: ryuheechul
- License: mit
- Created: 2014-07-20T05:22:17.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2020-04-03T06:54:36.000Z (about 6 years ago)
- Last Synced: 2025-08-19T06:37:04.392Z (11 months ago)
- Language: Objective-C
- Size: 332 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RACAutoDisposer
[](http://cocoadocs.org/docsets/RACAutoDisposer)
[](http://cocoadocs.org/docsets/RACAutoDisposer)
[](http://cocoadocs.org/docsets/RACAutoDisposer)
### Have a trouble because your RAC Subscriptions are being called even though you want them to be gone after reuse your views like UITableViewCell?
## Solve the problem with adding few lines of code.
Just say you want the last subscription to be gone when this code called again.
```objective-c
@RACAutoDispose(@"[key-to-be-unique-in-a-scope]", {
[RACObserve(self, object)
subscribeNext:^(id x) {
// ...
}];
})
```
### !Need to implemnt RACAutoDisposerProtocol to the scope object include @RACAutoDispose code
```objective-c
@interface ScopeObjectIncludesRACAutoDisposeCode ()
```
Other wise you will have warnings and unreleased RACDisposals which is a memory issue.
### What do you mean scope?
if your @RACAutoDispose codes are in same object, then it is in same scope.
so keys need to be unique in a same scope to distinguish each disposals.
## How it works?
- RACAutoDisposer holds last RAC Disposals(subscriptions) by key and scope when @RACAutoDispose called.
- RACAutoDisposer dispose the last Disposal with same key when same code called again. and hold new ones again.
- RACAutoDisposer release disposals when the scope object is deallocated.
### Sample Project
open Example/RACAutoDisposer.xcworkspace and run and see the results in console.
## Usage
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
ARC, ReactiveCocoa.
## Installation
RACAutoDisposer is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
pod "RACAutoDisposer"
## Author
Ryu Heechul, ryuhcii@gmail.com
## License
RACAutoDisposer is available under the MIT license. See the LICENSE file for more info.
## Contribution
welcome your contributions!
send me pull requests or open a issue and give me an idea to make this better!