Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom resource disposal to RACDisposable #27

Closed
jspahrsummers opened this issue Aug 7, 2012 · 4 comments
Closed

Add custom resource disposal to RACDisposable #27

jspahrsummers opened this issue Aug 7, 2012 · 4 comments

Comments

@jspahrsummers
Copy link
Member

Maybe through a public -addDisposeBlock: method on RACDisposable.

For instance, I would like to retain the GCD semaphore in firstOrDefault:success:error:, and have it be released only when the subscribable is completely torn down.

@alanjrogers
Copy link
Member

This sounds like a good idea. On a related note, does a RACDisposable dispose itself when it is deallocated?

@jspahrsummers
Copy link
Member Author

@alanjrogers RACScopedDisposable does – vanilla RACDisposable does not.

@joshaber
Copy link
Member

joshaber commented Oct 9, 2012

I'm not entirely convinced this is necessary. Conceptually the disposable returned from -subscribe: encapsulates all the logic necessary to clean up that subscription. So it seems odd to be able to "add" to that. More typically, you'd just create a new disposable that does your custom work and disposes of the other disposable.

-first... (and -toArray) are a bit of a weird case that I don't think should drive our decisions.

And there are all the advantages of RACDisposable being immutable.

@jspahrsummers
Copy link
Member Author

👍 I don't know why composition didn't occur to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants