@@ -1444,20 +1444,33 @@ extension Signal {
14441444
14451445 /// Forward events from `self` with history: values of the returned signal
14461446 /// are a tuples whose first member is the previous value and whose second member
1447- /// is the current value.
1448- ///
1449- /// If an initial value is given, the returned `Signal` would emit tuples as soon as
1450- /// the first value is received. If `initial` is nil, the returned `Signal` would not
1451- /// emit any tuple until it has received at least two values.
1447+ /// is the current value. `initial` is supplied as the first member when `self`
1448+ /// sends its first value.
14521449 ///
14531450 /// - parameters:
1454- /// - initial: An optional initial value.
1451+ /// - initial: A value that will be combined with the first value sent by
1452+ /// `self`.
1453+ ///
1454+ /// - returns: A signal that sends tuples that contain previous and current
1455+ /// sent values of `self`.
1456+ public func combinePrevious( _ initial: Value ) -> Signal < ( Value , Value ) , Error > {
1457+ return scan ( ( initial, initial) ) { previousCombinedValues, newValue in
1458+ return ( previousCombinedValues. 1 , newValue)
1459+ }
1460+ }
1461+
1462+ /// Forward events from `self` with history: values of the returned signal
1463+ /// are a tuples whose first member is the previous value and whose second member
1464+ /// is the current value.
1465+ ///
1466+ /// The returned `Signal` would not emit any tuple until it has received at least two
1467+ /// values.
14551468 ///
14561469 /// - returns: A signal that sends tuples that contain previous and current
14571470 /// sent values of `self`.
1458- public func combinePrevious( _ initial : Value ? = nil ) -> Signal < ( Value , Value ) , Error > {
1471+ public func combinePrevious( ) -> Signal < ( Value , Value ) , Error > {
14591472 return Signal < ( Value , Value ) , Error > { observer in
1460- var previous = initial
1473+ var previous : Value ?
14611474
14621475 return self . observe { event in
14631476 switch event {
0 commit comments