Skip to content

Commit 5dd2eeb

Browse files
mluisbrownactions-user
authored andcommitted
Run swift-format
1 parent 14c3162 commit 5dd2eeb

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,14 +219,15 @@ public final class Store<State, Action> {
219219
return .none
220220
}
221221
)
222-
localStore.parentDisposable = self.$state.producer.startWithValues { [weak localStore] state in
222+
localStore.parentDisposable = self.$state.producer.startWithValues {
223+
[weak localStore] state in
223224
guard let localStore = localStore else { return }
224225
localStore.state = extractLocalState(state) ?? localStore.state
225226
}
226227
return localStore
227228
}
228229
}
229-
230+
230231
/// Scopes the store to a producer of stores of more local state and local actions.
231232
///
232233
/// - Parameter toLocalState: A function that transforms a producer of `State` into a producer
@@ -238,25 +239,25 @@ public final class Store<State, Action> {
238239
) -> Effect<Store<LocalState, Action>, Never> {
239240
self.producerScope(state: toLocalState, action: { $0 })
240241
}
241-
242+
242243
func send(_ action: Action) {
243244
if !self.isSending {
244245
self.synchronousActionsToSend.append(action)
245246
} else {
246247
self.bufferedActions.append(action)
247248
return
248249
}
249-
250+
250251
while !self.synchronousActionsToSend.isEmpty || !self.bufferedActions.isEmpty {
251252
let action =
252253
!self.synchronousActionsToSend.isEmpty
253254
? self.synchronousActionsToSend.removeFirst()
254255
: self.bufferedActions.removeFirst()
255-
256+
256257
self.isSending = true
257258
let effect = self.reducer(&self.state, action)
258259
self.isSending = false
259-
260+
260261
var didComplete = false
261262
let effectID = UUID()
262263

@@ -281,34 +282,34 @@ public final class Store<State, Action> {
281282
)
282283
let effectDisposable = effect.start(observer)
283284
isProcessingEffects = false
284-
285+
285286
if !didComplete {
286287
self.effectDisposables[effectID] = effectDisposable
287288
} else {
288289
effectDisposable.dispose()
289290
}
290291
}
291292
}
292-
293+
293294
/// Returns a "stateless" store by erasing state to `Void`.
294295
public var stateless: Store<Void, Action> {
295296
self.scope(state: { _ in () })
296297
}
297-
298+
298299
/// Returns an "actionless" store by erasing action to `Never`.
299300
public var actionless: Store<State, Never> {
300301
func absurd<A>(_ never: Never) -> A {}
301302
return self.scope(state: { $0 }, action: absurd)
302303
}
303-
304+
304305
private init(
305306
initialState: State,
306307
reducer: @escaping (inout State, Action) -> Effect<Action, Never>
307308
) {
308309
self.reducer = reducer
309310
self.state = initialState
310311
}
311-
312+
312313
deinit {
313314
self.parentDisposable?.dispose()
314315
self.effectDisposables.keys.forEach { id in
@@ -322,30 +323,30 @@ public final class Store<State, Action> {
322323
public struct Produced<Value>: SignalProducerConvertible {
323324
private let _producer: Effect<Value, Never>
324325
private let comparator: (Value, Value) -> Bool
325-
326+
326327
public var producer: Effect<Value, Never> {
327328
_producer.skipRepeats(comparator)
328329
}
329-
330+
330331
init(
331332
by upstream: Effect<Value, Never>,
332333
isEqual: @escaping (Value, Value) -> Bool
333334
) {
334335
self._producer = upstream
335336
self.comparator = isEqual
336337
}
337-
338+
338339
init(by upstream: Effect<Value, Never>) where Value: Equatable {
339340
self.init(by: upstream, isEqual: ==)
340341
}
341-
342+
342343
/// Returns the resulting producer of a given key path.
343344
public subscript<LocalValue>(
344345
dynamicMember keyPath: KeyPath<Value, LocalValue>
345346
) -> Effect<LocalValue, Never> where LocalValue: Equatable {
346347
self.producer.map(keyPath).skipRepeats()
347348
}
348-
349+
349350
/// Returns the resulting producer of a given key path.
350351
public subscript<LocalValue>(
351352
dynamicMember keyPath: KeyPath<Value, LocalValue>
@@ -355,9 +356,9 @@ public struct Produced<Value>: SignalProducerConvertible {
355356
}
356357

357358
@available(
358-
*, deprecated,
359-
message:
360-
"""
359+
*, deprecated,
360+
message:
361+
"""
361362
Consider using `Produced<State>` instead, this typealias is added for backward compatibility and will be removed in the next major release.
362363
"""
363364
)

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,15 +4,15 @@ import XCTest
44
@testable import ComposableArchitecture
55

66
final class StoreTests: XCTestCase {
7-
7+
88
func testProducedMapping() {
99
struct ChildState: Equatable {
1010
var value: Int = 0
1111
}
1212
struct ParentState: Equatable {
1313
var child: ChildState = .init()
1414
}
15-
15+
1616
let store = Store<ParentState, Void>(
1717
initialState: ParentState(),
1818
reducer: Reducer { state, _, _ in
@@ -21,18 +21,18 @@ final class StoreTests: XCTestCase {
2121
},
2222
environment: ()
2323
)
24-
24+
2525
let viewStore = ViewStore(store)
2626
var values: [Int] = []
27-
27+
2828
viewStore.produced.child.value.startWithValues { value in
2929
values.append(value)
3030
}
31-
31+
3232
viewStore.send(())
3333
viewStore.send(())
3434
viewStore.send(())
35-
35+
3636
XCTAssertEqual(values, [0, 1, 2, 3])
3737
}
3838

0 commit comments

Comments
 (0)