This repository was archived by the owner on Dec 5, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -847,33 +847,6 @@ extension ColdSignal {
847847 }
848848 }
849849
850- /// Merges a ColdSignal of HotSignals down into a single HotSignal, biased toward the
851- /// signals added earlier.
852- ///
853- /// evidence - Used to prove to the typechecker that the receiver is
854- /// a signal of signals. Simply pass in the `identity` function.
855- ///
856- /// Returns a signal that will forward events from the original signals
857- /// as they arrive.
858- public func merge< U> ( evidence: ColdSignal -> ColdSignal < HotSignal < U > > ) -> HotSignal < U > {
859- return HotSignal < U > . weak { sink in
860- let disposable = CompositeDisposable ( )
861-
862- evidence ( self ) . startWithSink { selfDisposable in
863- disposable. addDisposable ( selfDisposable)
864-
865- return Event . sink ( next: { signal in
866- let innerDisposable = signal. observe ( sink)
867- disposable. addDisposable ( innerDisposable)
868-
869- return ( )
870- } )
871- }
872-
873- return disposable
874- }
875- }
876-
877850 /// Maps each value that the receiver sends to a new signal, then merges the
878851 /// resulting signals together.
879852 ///
Original file line number Diff line number Diff line change @@ -562,16 +562,22 @@ extension HotSignal {
562562 }
563563
564564 /// Merges a SequenceType of HotSignals down into a single HotSignal, biased toward the
565- /// signals added earlier.
565+ /// signals appearing earlier in the sequence .
566566 ///
567567 /// The returned signal will automatically be destroyed when there are no
568568 /// more strong references to it, and no Disposables returned from observe()
569569 /// are still around.
570570 ///
571571 /// Returns a HotSignal that will forward changes from the original signals
572- /// as they arrive, starting with earlier ones.
573- public class func merge< S: SequenceType where S. Generator. Element == HotSignal < T > > ( values: S ) -> HotSignal < T > {
574- return ColdSignal . fromValues ( values) . merge ( identity)
572+ /// in the sequence, starting with earlier ones.
573+ public class func merge< S: SequenceType where S. Generator. Element == HotSignal < T > > ( signals: S ) -> HotSignal < T > {
574+ let ( signal, sink) = HotSignal< HotSignal< T>>. pipe( )
575+ let merged = signal. merge ( identity)
576+ var generator = signals. generate ( )
577+ while let signal: HotSignal < T > = generator. next ( ) {
578+ sink. put ( signal)
579+ }
580+ return merged
575581 }
576582
577583 /// Maps each value that the receiver sends to a new signal, then merges the
You can’t perform that action at this time.
0 commit comments