Skip to content

Commit 0ef101d

Browse files
authored
Merge pull request #739 from ReactiveCocoa/event-promote-value
Signal: using Signal.Event.promoteValue
2 parents aa25add + a1f6c70 commit 0ef101d

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

Sources/Event.swift

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,17 +1015,23 @@ extension Signal.Event where Value == Never {
10151015
internal static func promoteValue<U>(_: U.Type) -> Transformation<U, Error> {
10161016
return { action, _ in
10171017
return { event in
1018-
switch event {
1019-
case .value:
1020-
fatalError("Never is impossible to construct")
1021-
case let .failed(error):
1022-
action(.failed(error))
1023-
case .completed:
1024-
action(.completed)
1025-
case .interrupted:
1026-
action(.interrupted)
1027-
}
1018+
action(event.promoteValue())
10281019
}
10291020
}
10301021
}
10311022
}
1023+
1024+
extension Signal.Event where Value == Never {
1025+
internal func promoteValue<U>() -> Signal<U, Error>.Event {
1026+
switch event {
1027+
case .value:
1028+
fatalError("Never is impossible to construct")
1029+
case let .failed(error):
1030+
return .failed(error)
1031+
case .completed:
1032+
return .completed
1033+
case .interrupted:
1034+
return .interrupted
1035+
}
1036+
}
1037+
}

Sources/Signal.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ extension Signal {
18481848
}
18491849

18501850
for (index, action) in builder.startHandlers.enumerated() where !lifetime.hasEnded {
1851-
lifetime += action(index, strategy) { observer.send($0.map { _ in fatalError() }) }
1851+
lifetime += action(index, strategy) { observer.send($0.promoteValue()) }
18521852
}
18531853
}
18541854
}

0 commit comments

Comments
 (0)