Skip to content

Commit 49184bf

Browse files
p4checomluisbrown
authored andcommitted
Run swift-format
1 parent 9301c0e commit 49184bf

File tree

13 files changed

+2106
-2106
lines changed

13 files changed

+2106
-2106
lines changed

Sources/ComposableArchitecture/Debugging/ReducerInstrumentation.swift

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,120 @@
11
#if canImport(os)
2-
import os.signpost
2+
import os.signpost
33

4-
extension Reducer {
5-
/// Instruments the reducer with
6-
/// [signposts](https://developer.apple.com/documentation/os/logging/recording_performance_data).
7-
/// Each invocation of the reducer will be measured by an interval, and the lifecycle of its
8-
/// effects will be measured with interval and event signposts.
9-
///
10-
/// To use, build your app for Instruments (⌘I), create a blank instrument, and then use the "+"
11-
/// icon at top right to add the signpost instrument. Start recording your app (red button at top
12-
/// left) and then you should see timing information for every action sent to the store and every
13-
/// effect executed.
14-
///
15-
/// Effect instrumentation can be particularly useful for inspecting the lifecycle of long-living
16-
/// effects. For example, if you start an effect (e.g. a location manager) in `onAppear` and
17-
/// forget to tear down the effect in `onDisappear`, it will clearly show in Instruments that the
18-
/// effect never completed.
19-
///
20-
/// - Parameters:
21-
/// - prefix: A string to print at the beginning of the formatted message for the signpost.
22-
/// - log: An `OSLog` to use for signposts.
23-
/// - Returns: A reducer that has been enhanced with instrumentation.
24-
public func signpost(
25-
_ prefix: String = "",
26-
log: OSLog = OSLog(
27-
subsystem: "co.pointfree.composable-architecture",
28-
category: "Reducer Instrumentation"
29-
)
30-
) -> Self {
31-
guard log.signpostsEnabled else { return self }
4+
extension Reducer {
5+
/// Instruments the reducer with
6+
/// [signposts](https://developer.apple.com/documentation/os/logging/recording_performance_data).
7+
/// Each invocation of the reducer will be measured by an interval, and the lifecycle of its
8+
/// effects will be measured with interval and event signposts.
9+
///
10+
/// To use, build your app for Instruments (⌘I), create a blank instrument, and then use the "+"
11+
/// icon at top right to add the signpost instrument. Start recording your app (red button at top
12+
/// left) and then you should see timing information for every action sent to the store and every
13+
/// effect executed.
14+
///
15+
/// Effect instrumentation can be particularly useful for inspecting the lifecycle of long-living
16+
/// effects. For example, if you start an effect (e.g. a location manager) in `onAppear` and
17+
/// forget to tear down the effect in `onDisappear`, it will clearly show in Instruments that the
18+
/// effect never completed.
19+
///
20+
/// - Parameters:
21+
/// - prefix: A string to print at the beginning of the formatted message for the signpost.
22+
/// - log: An `OSLog` to use for signposts.
23+
/// - Returns: A reducer that has been enhanced with instrumentation.
24+
public func signpost(
25+
_ prefix: String = "",
26+
log: OSLog = OSLog(
27+
subsystem: "co.pointfree.composable-architecture",
28+
category: "Reducer Instrumentation"
29+
)
30+
) -> Self {
31+
guard log.signpostsEnabled else { return self }
3232

33-
// NB: Prevent rendering as "N/A" in Instruments
34-
let zeroWidthSpace = "\u{200B}"
33+
// NB: Prevent rendering as "N/A" in Instruments
34+
let zeroWidthSpace = "\u{200B}"
3535

36-
let prefix = prefix.isEmpty ? zeroWidthSpace : "[\(prefix)] "
36+
let prefix = prefix.isEmpty ? zeroWidthSpace : "[\(prefix)] "
3737

38-
return Self { state, action, environment in
39-
var actionOutput: String!
40-
if log.signpostsEnabled {
41-
actionOutput = debugCaseOutput(action)
42-
os_signpost(.begin, log: log, name: "Action", "%s%s", prefix, actionOutput)
43-
}
44-
let effects = self.run(&state, action, environment)
45-
if log.signpostsEnabled {
46-
os_signpost(.end, log: log, name: "Action")
47-
return
48-
effects
49-
.effectSignpost(prefix, log: log, actionOutput: actionOutput)
38+
return Self { state, action, environment in
39+
var actionOutput: String!
40+
if log.signpostsEnabled {
41+
actionOutput = debugCaseOutput(action)
42+
os_signpost(.begin, log: log, name: "Action", "%s%s", prefix, actionOutput)
43+
}
44+
let effects = self.run(&state, action, environment)
45+
if log.signpostsEnabled {
46+
os_signpost(.end, log: log, name: "Action")
47+
return
48+
effects
49+
.effectSignpost(prefix, log: log, actionOutput: actionOutput)
50+
}
51+
return effects
5052
}
51-
return effects
5253
}
5354
}
54-
}
5555

56-
extension Effect where Failure == Never {
57-
func effectSignpost(
58-
_ prefix: String,
59-
log: OSLog,
60-
actionOutput: String
61-
) -> Self {
62-
let sid = OSSignpostID(log: log)
56+
extension Effect where Failure == Never {
57+
func effectSignpost(
58+
_ prefix: String,
59+
log: OSLog,
60+
actionOutput: String
61+
) -> Self {
62+
let sid = OSSignpostID(log: log)
6363

64-
switch self.operation {
65-
case .none:
66-
return self
64+
switch self.operation {
65+
case .none:
66+
return self
6767
case let .producer(producer):
68-
return .init(
68+
return .init(
6969
operation: .producer(
7070
producer
7171
.on(
7272
starting: {
73-
os_signpost(
74-
.begin, log: log, name: "Effect", signpostID: sid, "%sStarted from %s", prefix,
73+
os_signpost(
74+
.begin, log: log, name: "Effect", signpostID: sid, "%sStarted from %s", prefix,
7575
actionOutput
7676
)
7777
},
7878
completed: {
7979
os_signpost(.end, log: log, name: "Effect", signpostID: sid, "%sFinished", prefix)
80-
},
80+
},
8181
disposed: {
82-
os_signpost(
82+
os_signpost(
8383
.end, log: log, name: "Effect", signpostID: sid, "%sCancelled", prefix)
84-
},
84+
},
8585
value: { value in
8686
os_signpost(
8787
.event, log: log, name: "Effect Output", "%sOutput from %s", prefix,
8888
actionOutput
8989
)
90-
}
90+
}
91+
)
9192
)
9293
)
93-
)
94-
case let .run(priority, operation):
95-
return .init(
96-
operation: .run(priority) { send in
97-
os_signpost(
98-
.begin, log: log, name: "Effect", signpostID: sid, "%sStarted from %s", prefix,
99-
actionOutput
100-
)
101-
await operation(
102-
Send { action in
103-
os_signpost(
104-
.event, log: log, name: "Effect Output", "%sOutput from %s", prefix, actionOutput
105-
)
106-
send(action)
94+
case let .run(priority, operation):
95+
return .init(
96+
operation: .run(priority) { send in
97+
os_signpost(
98+
.begin, log: log, name: "Effect", signpostID: sid, "%sStarted from %s", prefix,
99+
actionOutput
100+
)
101+
await operation(
102+
Send { action in
103+
os_signpost(
104+
.event, log: log, name: "Effect Output", "%sOutput from %s", prefix, actionOutput
105+
)
106+
send(action)
107+
}
108+
)
109+
if Task.isCancelled {
110+
os_signpost(.end, log: log, name: "Effect", signpostID: sid, "%sCancelled", prefix)
107111
}
108-
)
109-
if Task.isCancelled {
110-
os_signpost(.end, log: log, name: "Effect", signpostID: sid, "%sCancelled", prefix)
112+
os_signpost(.end, log: log, name: "Effect", signpostID: sid, "%sFinished", prefix)
111113
}
112-
os_signpost(.end, log: log, name: "Effect", signpostID: sid, "%sFinished", prefix)
113-
}
114-
)
114+
)
115+
}
115116
}
116117
}
117-
}
118118
#endif
119119

120120
func debugCaseOutput(_ value: Any) -> String {

Sources/ComposableArchitecture/Effect.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ extension Effect {
461461
await operation(
462462
Send { action in
463463
send(transform(action))
464-
}
465-
)
464+
}
465+
)
466466
}
467467
)
468468
}

Sources/ComposableArchitecture/Effects/Cancellation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ extension Effect {
7676
}
7777
}
7878

79-
cancellationCancellables[id, default: []].insert(
79+
cancellationCancellables[id, default: []].insert(
8080
cancellationDisposable
81-
)
81+
)
8282

8383
return SignalProducer(values.value)
8484
.concat(subject.output.producer)

Sources/ComposableArchitecture/Effects/SignalProducer.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ extension Effect {
101101
// bug was fixed in iOS 14, but to remain compatible with iOS 13 and higher we need to do
102102
// a little trickery to fail in a slightly different way.
103103
self.init(SignalProducer(error: error))
104-
}
104+
}
105105

106106
/// Creates an effect that can supply a single value asynchronously in the future.
107107
///
@@ -150,7 +150,7 @@ extension Effect {
150150
observer.send(error: error)
151151
}
152152
}
153-
}
153+
}
154154
)
155155
}
156156

@@ -526,7 +526,7 @@ extension SignalProducer {
526526
outputType: NewValue.Type = NewValue.self,
527527
failureType: NewError.Type = NewError.self
528528
) -> Effect<NewValue, NewError> {
529-
self
529+
self
530530
.flatMapError { _ in .empty }
531531
.flatMap(.latest) { _ in .empty }
532532
.eraseToEffect()

Sources/ComposableArchitecture/Internal/Deprecations.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -406,19 +406,19 @@ extension WithViewStore {
406406
// MARK: - Deprecated after 0.39.0:
407407

408408
#if canImport(SwiftUI)
409-
extension CaseLet {
410-
@available(*, deprecated, renamed: "EnumState")
411-
public typealias GlobalState = EnumState
409+
extension CaseLet {
410+
@available(*, deprecated, renamed: "EnumState")
411+
public typealias GlobalState = EnumState
412412

413-
@available(*, deprecated, renamed: "EnumAction")
414-
public typealias GlobalAction = EnumAction
413+
@available(*, deprecated, renamed: "EnumAction")
414+
public typealias GlobalAction = EnumAction
415415

416-
@available(*, deprecated, renamed: "CaseState")
417-
public typealias LocalState = CaseState
416+
@available(*, deprecated, renamed: "CaseState")
417+
public typealias LocalState = CaseState
418418

419-
@available(*, deprecated, renamed: "CaseAction")
420-
public typealias LocalAction = CaseAction
421-
}
419+
@available(*, deprecated, renamed: "CaseAction")
420+
public typealias LocalAction = CaseAction
421+
}
422422
#endif
423423

424424
#if DEBUG

Sources/ComposableArchitecture/Store.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,24 +373,24 @@ public final class Store<State, Action> {
373373
}
374374
},
375375
completed: { [weak self] in
376-
self?.threadCheck(status: .effectCompletion(action))
377-
boxedTask.wrappedValue?.cancel()
378-
didComplete = true
376+
self?.threadCheck(status: .effectCompletion(action))
377+
boxedTask.wrappedValue?.cancel()
378+
didComplete = true
379379
self?.effectDisposables.removeValue(forKey: uuid)?.dispose()
380-
},
380+
},
381381
interrupted: { [weak self] in
382382
boxedTask.wrappedValue?.cancel()
383383
didComplete = true
384384
self?.effectDisposables.removeValue(forKey: uuid)?.dispose()
385-
}
385+
}
386386
)
387387

388388
let effectDisposable = CompositeDisposable()
389389
effectDisposable += producer.start(observer)
390390
effectDisposable += AnyDisposable { [weak self] in
391391
self?.threadCheck(status: .effectCompletion(action))
392392
self?.effectDisposables.removeValue(forKey: uuid)?.dispose()
393-
}
393+
}
394394

395395
if !didComplete {
396396
let task = Task<Void, Never> { @MainActor in

0 commit comments

Comments
 (0)