Skip to content

Commit 81d795b

Browse files
mluisbrownactions-user
authored andcommitted
Run swift-format
1 parent 266fb53 commit 81d795b

File tree

3 files changed

+35
-34
lines changed

3 files changed

+35
-34
lines changed

Sources/ComposableArchitecture/Store.swift

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import ReactiveSwift
99
public final class Store<State, Action> {
1010
@MutableProperty
1111
private(set) var state: State
12-
12+
1313
private var isSending = false
1414
private let reducer: (inout State, Action) -> Effect<Action, Never>
1515
private var synchronousActionsToSend: [Action] = []
1616
private var bufferedActions: [Action] = []
1717
internal var effectDisposables: [UUID: Disposable] = [:]
1818
internal var parentDisposable: Disposable?
19-
19+
2020
/// Initializes a store from an initial state, a reducer, and an environment.
2121
///
2222
/// - Parameters:
@@ -33,7 +33,7 @@ public final class Store<State, Action> {
3333
reducer: { reducer.run(&$0, $1, environment) }
3434
)
3535
}
36-
36+
3737
/// Scopes the store to one that exposes local state and actions.
3838
///
3939
/// This can be useful for deriving new stores to hand to child views in an application. For
@@ -179,7 +179,7 @@ public final class Store<State, Action> {
179179
}
180180
return localStore
181181
}
182-
182+
183183
/// Scopes the store to one that exposes local state.
184184
///
185185
/// - Parameter toLocalState: A function that transforms `State` into `LocalState`.
@@ -189,7 +189,7 @@ public final class Store<State, Action> {
189189
) -> Store<LocalState, Action> {
190190
self.scope(state: toLocalState, action: { $0 })
191191
}
192-
192+
193193
/// Scopes the store to a producer of stores of more local state and local actions.
194194
///
195195
/// - Parameters:
@@ -201,14 +201,14 @@ public final class Store<State, Action> {
201201
state toLocalState: @escaping (Effect<State, Never>) -> Effect<LocalState, Never>,
202202
action fromLocalAction: @escaping (LocalAction) -> Action
203203
) -> Effect<Store<LocalState, LocalAction>, Never> {
204-
204+
205205
func extractLocalState(_ state: State) -> LocalState? {
206206
var localState: LocalState?
207207
_ = toLocalState(Effect(value: state))
208208
.startWithValues { localState = $0 }
209209
return localState
210210
}
211-
211+
212212
return toLocalState(self.$state.producer)
213213
.map { localState in
214214
let localStore = Store<LocalState, LocalAction>(
@@ -219,15 +219,16 @@ public final class Store<State, Action> {
219219
return .none
220220
}
221221
)
222-
223-
localStore.parentDisposable = self.$state.producer.startWithValues { [weak localStore] state in
222+
223+
localStore.parentDisposable = self.$state.producer.startWithValues {
224+
[weak localStore] state in
224225
guard let localStore = localStore else { return }
225226
localStore.state = extractLocalState(state) ?? localStore.state
226227
}
227228
return localStore
228229
}
229230
}
230-
231+
231232
/// Scopes the store to a producer of stores of more local state and local actions.
232233
///
233234
/// - Parameter toLocalState: A function that transforms a producer of `State` into a producer
@@ -239,30 +240,30 @@ public final class Store<State, Action> {
239240
) -> Effect<Store<LocalState, Action>, Never> {
240241
self.producerScope(state: toLocalState, action: { $0 })
241242
}
242-
243+
243244
func send(_ action: Action) {
244245
if !self.isSending {
245246
self.synchronousActionsToSend.append(action)
246247
} else {
247248
self.bufferedActions.append(action)
248249
return
249250
}
250-
251+
251252
while !self.synchronousActionsToSend.isEmpty || !self.bufferedActions.isEmpty {
252253
let action =
253254
!self.synchronousActionsToSend.isEmpty
254255
? self.synchronousActionsToSend.removeFirst()
255256
: self.bufferedActions.removeFirst()
256-
257+
257258
self.isSending = true
258259
let effect = self.reducer(&self.state, action)
259260
self.isSending = false
260-
261+
261262
var didComplete = false
262263
let effectID = UUID()
263-
264+
264265
var isProcessingEffects = true
265-
266+
266267
let observer = Signal<Action, Never>.Observer(
267268
value: { [weak self] action in
268269
if isProcessingEffects {
@@ -283,34 +284,34 @@ public final class Store<State, Action> {
283284
)
284285
let effectDisposable = effect.start(observer)
285286
isProcessingEffects = false
286-
287+
287288
if !didComplete {
288289
self.effectDisposables[effectID] = effectDisposable
289290
} else {
290291
effectDisposable.dispose()
291292
}
292293
}
293294
}
294-
295+
295296
/// Returns a "stateless" store by erasing state to `Void`.
296297
public var stateless: Store<Void, Action> {
297298
self.scope(state: { _ in () })
298299
}
299-
300+
300301
/// Returns an "actionless" store by erasing action to `Never`.
301302
public var actionless: Store<State, Never> {
302303
func absurd<A>(_ never: Never) -> A {}
303304
return self.scope(state: { $0 }, action: absurd)
304305
}
305-
306+
306307
private init(
307308
initialState: State,
308309
reducer: @escaping (inout State, Action) -> Effect<Action, Never>
309310
) {
310311
self.reducer = reducer
311312
self.state = initialState
312313
}
313-
314+
314315
deinit {
315316
self.parentDisposable?.dispose()
316317
self.effectDisposables.keys.forEach { id in
@@ -323,11 +324,11 @@ public final class Store<State, Action> {
323324
@dynamicMemberLookup
324325
public struct Produced<Value>: SignalProducerConvertible {
325326
public let producer: Effect<Value, Never>
326-
327+
327328
init(by upstream: Effect<Value, Never>) {
328329
self.producer = upstream
329330
}
330-
331+
331332
/// Returns the resulting producer of a given key path.
332333
public subscript<LocalValue>(
333334
dynamicMember keyPath: KeyPath<Value, LocalValue>
@@ -337,9 +338,9 @@ public struct Produced<Value>: SignalProducerConvertible {
337338
}
338339

339340
@available(
340-
*, deprecated,
341-
message:
342-
"""
341+
*, deprecated,
342+
message:
343+
"""
343344
Consider using `Produced<State>` instead, this typealias is added for backward compatibility and will be removed in the next major release.
344345
"""
345346
)

Sources/ComposableArchitecture/ViewStore.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public final class ViewStore<State, Action> {
6868
"""
6969
)
7070
public var publisher: StoreProducer<State> { produced }
71-
71+
7272
internal var viewDisposable: Disposable?
7373

7474
/// Initializes a view store from a store.
@@ -259,7 +259,7 @@ public final class ViewStore<State, Action> {
259259
self.binding(send: { _ in action })
260260
}
261261
#endif
262-
262+
263263
deinit {
264264
viewDisposable?.dispose()
265265
}

Tests/ComposableArchitectureTests/StoreTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import XCTest
44
@testable import ComposableArchitecture
55

66
final class StoreTests: XCTestCase {
7-
7+
88
func testEffectDisposablesDeinitialization() {
99
enum Action {
1010
case triggerDelay
@@ -14,7 +14,7 @@ final class StoreTests: XCTestCase {
1414
switch action {
1515
case .triggerDelay:
1616
return Effect(value: .delayDidComplete).delay(1, on: mainQueue)
17-
17+
1818
case .delayDidComplete:
1919
return .none
2020
}
@@ -25,16 +25,16 @@ final class StoreTests: XCTestCase {
2525
reducer: delayedReducer,
2626
environment: QueueScheduler.main
2727
)
28-
28+
2929
store.send(.triggerDelay)
3030
store.send(.triggerDelay)
3131
store.send(.triggerDelay)
3232
store.send(.delayDidComplete)
33-
33+
3434
XCTAssertEqual(store.effectDisposables.count, 3)
35-
35+
3636
XCTWaiter().wait(for: [XCTestExpectation()], timeout: 1.1)
37-
37+
3838
XCTAssertEqual(store.effectDisposables.count, 0)
3939
}
4040

0 commit comments

Comments
 (0)