Skip to content

Commit

Permalink
Merge pull request #37 from ReactiveCocoa/update-dep
Browse files Browse the repository at this point in the history
Update ReactiveSwift to 2.0.1.
  • Loading branch information
andersio authored Aug 19, 2017
2 parents 95f55e5 + ffa13d8 commit 55a210e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
github "Quick/Nimble" "v7.0.1"
github "Quick/Quick" "v1.1.0"
github "ReactiveCocoa/ReactiveObjC" "3.0.0"
github "ReactiveCocoa/ReactiveSwift" "2.0.1"
github "antitypical/Result" "3.2.3"
github "jspahrsummers/xcconfigs" "3d9d99634cae6d586e272543d527681283b33eb0"
github "ReactiveCocoa/ReactiveSwift" "2.0.0"
25 changes: 24 additions & 1 deletion ReactiveObjCBridgeTests/ObjectiveCBridgingSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,14 @@ class ObjectiveCBridgingSpec: QuickSpec {
it("should start once per subscription") {
var subscriptions = 0

let producer = SignalProducer { () -> Result<NSNumber, NoError> in
let producer = SignalProducer<NSNumber, NoError> { () -> Result<NSNumber, NoError> in
defer {
subscriptions += 1
}

return .success(subscriptions as NSNumber)
}

let racSignal = producer.bridged

expect(racSignal.first()) == 0
Expand Down Expand Up @@ -563,3 +564,25 @@ class ObjectiveCBridgingSpec: QuickSpec {
}
}
}

extension SignalProducer where Error == NoError {
/// Create a `SignalProducer` that will attempt the given operation once for
/// each invocation of `start()`.
///
/// Upon success, the started signal will send the resulting value then
/// complete. Upon failure, the started signal will fail with the error that
/// occurred.
///
/// - parameters:
/// - action: A closure that returns instance of `Result`.
public init(_ action: @escaping () -> Result<Value, NoError>) {
self.init { observer, _ in
action().analysis(ifSuccess: { value in
observer.send(value: value)
observer.sendCompleted()
}, ifFailure: { error in
observer.send(error: error)
})
}
}
}

0 comments on commit 55a210e

Please sign in to comment.