-
Notifications
You must be signed in to change notification settings - Fork 432
promoteError type inference.
#413
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2405,7 +2405,7 @@ extension Signal where Error == NoError { | |
| /// - _ An `ErrorType`. | ||
| /// | ||
| /// - returns: A signal that has an instantiatable `ErrorType`. | ||
| public func promoteError<F: Swift.Error>(_: F.Type) -> Signal<Value, F> { | ||
| public func promoteError<F: Swift.Error>(_: F.Type = F.self) -> Signal<Value, F> { | ||
| return Signal<Value, F> { observer in | ||
| return self.observe { event in | ||
| switch event { | ||
|
|
@@ -2422,6 +2422,21 @@ extension Signal where Error == NoError { | |
| } | ||
| } | ||
|
|
||
| /// Promote a signal that does not generate failures into one that can. | ||
| /// | ||
| /// - note: This does not actually cause failures to be generated for the | ||
| /// given signal, but makes it easier to combine with other signals | ||
| /// that may fail; for example, with operators like | ||
| /// `combineLatestWith`, `zipWith`, `flatten`, etc. | ||
| /// | ||
| /// - parameters: | ||
| /// - _ An `ErrorType`. | ||
| /// | ||
| /// - returns: A signal that has an instantiatable `ErrorType`. | ||
| public func promoteError(_: Error.Type = Error.self) -> Signal<Value, Error> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait why is this overload necessary?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It isn't necessary, just that it allows one adds SignalProducer<Int, CocoaError>.combineLatest(
SignalProducer<Int, CocoaError>.empty.promoteError(),
SignalProducer<Int, NoError>.empty.promoteError()
)The resulting SignalProducer<Int, CocoaError>.combineLatest(
SignalProducer<Int, CocoaError>.empty,
SignalProducer<Int, NoError>.empty.promoteError()
)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm very much 👎 for that. Since when has RAC promoted brainless thinking? :P A user calling this operator when they shouldn't is likely an error and shouldn't be silenced IMO.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps I should be more careful about my wordings. The overload does not add any capability, and is just a fast path when the compiler knows Say
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oooh that's right, because it's not possible to do negative conditions on extensions. This is a great idea then 👍 |
||
| return self | ||
| } | ||
|
|
||
| /// Forward events from `self` until `interval`. Then if signal isn't | ||
| /// completed yet, fails with `error` on `scheduler`. | ||
| /// | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1397,10 +1397,25 @@ extension SignalProducer where Error == NoError { | |
| /// - _ An `ErrorType`. | ||
| /// | ||
| /// - returns: A producer that has an instantiatable `ErrorType`. | ||
| public func promoteError<F: Swift.Error>(_: F.Type) -> SignalProducer<Value, F> { | ||
| public func promoteError<F: Swift.Error>(_: F.Type = F.self) -> SignalProducer<Value, F> { | ||
| return lift { $0.promoteError(F.self) } | ||
| } | ||
|
|
||
| /// Promote a producer that does not generate failures into one that can. | ||
| /// | ||
| /// - note: This does not actually cause failers to be generated for the | ||
| /// given producer, but makes it easier to combine with other | ||
| /// producers that may fail; for example, with operators like | ||
| /// `combineLatestWith`, `zipWith`, `flatten`, etc. | ||
| /// | ||
| /// - parameters: | ||
| /// - _ An `ErrorType`. | ||
| /// | ||
| /// - returns: A producer that has an instantiatable `ErrorType`. | ||
| public func promoteError(_: Error.Type = Error.self) -> SignalProducer<Value, Error> { | ||
| return self | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
| } | ||
|
|
||
| /// Forward events from `self` until `interval`. Then if producer isn't | ||
| /// completed yet, fails with `error` on `scheduler`. | ||
| /// | ||
|
|
||
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.
Awesome