@@ -1444,18 +1444,37 @@ extension Signal {
1444
1444
1445
1445
/// Forward events from `self` with history: values of the returned signal
1446
1446
/// 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.
1452
1449
///
1453
1450
/// - parameters:
1454
- /// - initial: An optional initial value.
1451
+ /// - initial: A value that will be combined with the first value sent by
1452
+ /// `self`.
1455
1453
///
1456
1454
/// - returns: A signal that sends tuples that contain previous and current
1457
1455
/// sent values of `self`.
1458
- public func combinePrevious( _ initial: Value ? = nil ) -> Signal < ( Value , Value ) , Error > {
1456
+ public func combinePrevious( _ initial: Value ) -> Signal < ( Value , Value ) , Error > {
1457
+ return combinePrevious ( initial: initial)
1458
+ }
1459
+
1460
+ /// Forward events from `self` with history: values of the returned signal
1461
+ /// are a tuples whose first member is the previous value and whose second member
1462
+ /// is the current value.
1463
+ ///
1464
+ /// The returned `Signal` would not emit any tuple until it has received at least two
1465
+ /// values.
1466
+ ///
1467
+ /// - returns: A signal that sends tuples that contain previous and current
1468
+ /// sent values of `self`.
1469
+ public func combinePrevious( ) -> Signal < ( Value , Value ) , Error > {
1470
+ return combinePrevious ( initial: nil )
1471
+ }
1472
+
1473
+ /// Implementation detail of `combinePrevious`. A default argument of a `nil` initial
1474
+ /// is deliberately avoided, since in the case of `Value` being an optional, the
1475
+ /// `nil` literal would be materialized as `Optional<Value>.none` instead of `Value`,
1476
+ /// thus changing the semantic.
1477
+ private func combinePrevious( initial: Value ? ) -> Signal < ( Value , Value ) , Error > {
1459
1478
return Signal < ( Value , Value ) , Error > { observer in
1460
1479
var previous = initial
1461
1480
0 commit comments