Skip to content

Commit e29f6ec

Browse files
committed
Comments and fireCount Changes
Improved comments. Don't reset the fireCount when clearing the lastDataFired. Remove unnecessary checks on fireCount.
1 parent 83728f8 commit e29f6ec

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Signals/Signal.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Signal<T> {
1818
/// The last data that the signal was fired with.
1919
public var lastDataFired: T? = nil
2020

21-
/// Should the Signal retain a reference to the last data that it was fired with?
21+
/// Whether or not the Signal should retain a reference to the last data it was fired with. Defaults to false.
2222
public var retainLastData: Bool = false
2323

2424
/// All the listeners listening to the Signal.
@@ -35,7 +35,7 @@ public class Signal<T> {
3535

3636
/// Signal Initializer
3737
///
38-
/// - parameter retainLastData: Should the Signal retain a reference to the last data that it was fired with?
38+
/// - parameter retainLastData: Whether or not the Signal should retain a reference to the last data it was fired with. Defaults to false.
3939
public init(retainLastData: Bool = false) {
4040
fireCount = 0
4141
self.retainLastData = retainLastData
@@ -85,7 +85,7 @@ public class Signal<T> {
8585
/// - parameter callback: The closure to invoke whenever the signal fires.
8686
public func listenPast(listener: AnyObject, callback: (T) -> Void) -> SignalListener<T> {
8787
let signalListener = self.listen(listener, callback: callback)
88-
if let lastDataFired = lastDataFired where fireCount > 0 {
88+
if let lastDataFired = lastDataFired {
8989
signalListener.callback(lastDataFired)
9090
}
9191
return signalListener
@@ -99,7 +99,7 @@ public class Signal<T> {
9999
/// - parameter callback: The closure to invoke whenever the signal fires.
100100
public func listenPastOnce(listener: AnyObject, callback: (T) -> Void) -> SignalListener<T> {
101101
let signalListener = self.listen(listener, callback: callback)
102-
if let lastDataFired = lastDataFired where fireCount > 0 {
102+
if let lastDataFired = lastDataFired {
103103
signalListener.callback(lastDataFired)
104104
signalListener.cancel()
105105
} else {
@@ -142,7 +142,6 @@ public class Signal<T> {
142142

143143
/// Clears the last fired data from the Signal and resets the fire count
144144
public func clearLastData() {
145-
fireCount = 0
146145
lastDataFired = nil
147146
}
148147
}

0 commit comments

Comments
 (0)