-
Notifications
You must be signed in to change notification settings - Fork 429
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
Signal resource management with Lifetime
.
#404
Conversation
This makes sense to me. (Although I did think about it for quite a while because I wasn't sure.)
This change seems less necessary and also orthogonal. I'm not convinced we should do this. Unfortunately, this is all too late for 2.0, so it will also need to be changed to be a non-breaking change (adding an |
@mdiep Sadly as a new |
3.0 it is! Hopefully we/I can be a little more prompt with 3.0. We could ship as soon as Xcode 9 / Swift 4 ship this fall. |
6edbfb4
to
b86a3c9
Compare
Sources/Flatten.swift
Outdated
return disposable | ||
return Signal<Value.Value, Error> { relayObserver, lifetime in | ||
let disposable = self.observeConcurrent(relayObserver, limit, lifetime) | ||
_ = (disposable?.dispose).map(lifetime.observeEnded) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly dislike using map
like this. map
shouldn't be used for side effects. This is also not very clear IMO.
I think we're better off with if let dispose = disposable?.dispose { lifetime.observeEnded(dispose) }
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lifetime += disposable
should work, and I have already replaced most of them.
This should be mentioned in the changelog, but otherwise it looks great. 👍 |
Follow-up to #334.
This is not as trivially migratable as #334, since
Signal
had a different design choice in the signal generator closure than theSignalProducer
. Let alone the fact that SE-0110 is not implemented in Swift 3, adding obstacles to automatic migration.Signal
generator signature to(Observer, Lifetime) -> Void
, so that it matches the style ofSignalProducer.init
.