Skip to content

Commit bf337d7

Browse files
vovabndrandersio
andauthored
replaced allEvents by allCases (#796)
* replaced allEvents by allCases * Deprecation for source compatibility * Fix a typo Co-authored-by: Anders Ha <[email protected]>
1 parent e4dbe09 commit bf337d7

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

Sources/EventLogger.swift

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,18 @@ import Foundation
1010

1111
/// A namespace for logging event types.
1212
public enum LoggingEvent {
13-
public enum Signal: String {
13+
public enum Signal: String, CaseIterable {
1414
case value, completed, failed, terminated, disposed, interrupted
1515

16-
public static let allEvents: Set<Signal> = [
17-
.value, .completed, .failed, .terminated, .disposed, .interrupted,
18-
]
16+
@available(*, deprecated, message:"Use `allCases` instead.")
17+
public static var allEvents: Set<Signal> { Set(allCases) }
1918
}
2019

21-
public enum SignalProducer: String {
20+
public enum SignalProducer: String, CaseIterable {
2221
case starting, started, value, completed, failed, terminated, disposed, interrupted
2322

24-
public static let allEvents: Set<SignalProducer> = [
25-
.starting, .started, .value, .completed, .failed, .terminated, .disposed, .interrupted,
26-
]
23+
@available(*, deprecated, message:"Use `allCases` instead.")
24+
public static var allEvents: Set<SignalProducer> { Set(allCases) }
2725
}
2826
}
2927

@@ -82,7 +80,7 @@ extension Signal {
8280
/// - logger: Logger that logs the events.
8381
///
8482
/// - returns: Signal that, when observed, logs the fired events.
85-
public func logEvents(identifier: String = "", events: Set<LoggingEvent.Signal> = LoggingEvent.Signal.allEvents, fileName: String = #file, functionName: String = #function, lineNumber: Int = #line, logger: @escaping EventLogger = defaultEventLog) -> Signal<Value, Error> {
83+
public func logEvents(identifier: String = "", events: Set<LoggingEvent.Signal> = Set(LoggingEvent.Signal.allCases), fileName: String = #file, functionName: String = #function, lineNumber: Int = #line, logger: @escaping EventLogger = defaultEventLog) -> Signal<Value, Error> {
8684
let logContext = LogContext(events: events,
8785
identifier: identifier,
8886
fileName: fileName,
@@ -116,7 +114,7 @@ extension SignalProducer {
116114
///
117115
/// - returns: Signal producer that, when started, logs the fired events.
118116
public func logEvents(identifier: String = "",
119-
events: Set<LoggingEvent.SignalProducer> = LoggingEvent.SignalProducer.allEvents,
117+
events: Set<LoggingEvent.SignalProducer> = Set(LoggingEvent.SignalProducer.allCases),
120118
fileName: String = #file,
121119
functionName: String = #function,
122120
lineNumber: Int = #line,

0 commit comments

Comments
 (0)