@@ -220,6 +220,22 @@ public extension ColdSignalType {
220220 }
221221 }
222222
223+ public func lift< U, F> ( _ transform: @escaping ( Signal < Value , ErrorType > ) -> ( Signal < U , F > , Signal < U , F > ) )
224+ -> ( ColdSignal < U , F > , ColdSignal < U , F > )
225+ {
226+ let ( pipeSignal, pipeObserver) = Signal < Value , ErrorType > . pipe ( )
227+ let ( left, right) = transform ( pipeSignal)
228+ let coldLeft = ColdSignal < U , F > { observer in
229+ left. add ( observer: observer)
230+ return self . coldSignal. startHandler ( pipeObserver)
231+ }
232+ let coldRight = ColdSignal < U , F > { observer in
233+ right. add ( observer: observer)
234+ return self . coldSignal. startHandler ( pipeObserver)
235+ }
236+ return ( coldLeft, coldRight)
237+ }
238+
223239 /// Maps each value in the signal to a new value.
224240 public func map< U> ( _ transform: @escaping ( Value ) -> U ) -> ColdSignal < U , ErrorType > {
225241 return lift { $0. map ( transform) }
@@ -235,6 +251,13 @@ public extension ColdSignalType {
235251 return lift { $0. filter ( predicate) }
236252 }
237253
254+ /// Splits the signal into two signals. The first signal in the tuple matches the
255+ /// predicate, the second signal does not match the predicate
256+ public func partition( _ predicate: @escaping ( Value ) -> Bool )
257+ -> ( ColdSignal < Value , ErrorType > , ColdSignal < Value , ErrorType > ) {
258+ return lift { $0. partition ( predicate) }
259+ }
260+
238261 /// Aggregate values into a single combined value. Mirrors the Swift Collection
239262 public func reduce< T> ( initial: T , _ combine: @escaping ( T , Value ) -> T ) -> ColdSignal < T , ErrorType > {
240263 return lift { $0. reduce ( initial: initial, combine) }
0 commit comments