Skip to content

Commit bef760c

Browse files
sebastianvarelaminuscorp
authored andcommitted
Swiftlint autocorrect
1 parent 18bdd03 commit bef760c

15 files changed

+123
-125
lines changed

Sources/MiniSwift/Action.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extension Action {
2626
public var innerTag: String {
2727
return String(describing: type(of: self))
2828
}
29-
29+
3030
/**
3131
Static method to retrieve the name of the action as a tag.action.
3232

Sources/MiniSwift/ActionReducer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ public class Reducer<A: Action>: Disposable {
2121
public let action: A.Type
2222
public let dispatcher: Dispatcher
2323
public let reducer: (A) -> Void
24-
24+
2525
private var disposable: Disposable!
26-
26+
2727
public init(of action: A.Type, on dispatcher: Dispatcher, reducer: @escaping (A) -> Void) {
2828
self.action = action
2929
self.dispatcher = dispatcher
3030
self.reducer = reducer
3131
self.disposable = build()
3232
}
33-
33+
3434
private func build() -> Disposable {
3535
let disposable = dispatcher.subscribe(tag: action.tag) {
3636
self.reducer($0)
3737
}
3838
return disposable
3939
}
40-
40+
4141
public func dispose() {
4242
disposable.dispose()
4343
}

Sources/MiniSwift/Dispatcher.swift

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ import NIOConcurrencyHelpers
2121
public typealias SubscriptionMap = SharedDictionary<String, OrderedSet<DispatcherSubscription>?>
2222

2323
final public class Dispatcher {
24-
24+
2525
public struct DispatchMode {
2626
// swiftlint:disable:next type_name nesting
2727
public enum UI {
2828
case sync, async
2929
}
3030
}
31-
31+
3232
public var subscriptionCount: Int {
3333
return subscriptionMap.innerDictionary.mapValues { set -> Int in
3434
guard let setValue = set else { return 0 }
3535
return setValue.count
3636
}
3737
.reduce(0, { $0 + $1.value })
3838
}
39-
39+
4040
public static let defaultPriority = 100
41-
41+
4242
private let internalQueue = DispatchQueue(label: "MiniSwift", qos: .userInitiated)
4343
private var subscriptionMap = SubscriptionMap()
4444
private var middleware = [Middleware]()
@@ -47,27 +47,27 @@ final public class Dispatcher {
4747
private var chain: Chain
4848
private var dispatching: Bool = false
4949
private var subscriptionCounter: Atomic<Int> = Atomic<Int>(value: 0)
50-
50+
5151
public init() {
5252
root = RootChain(map: subscriptionMap)
5353
chain = root
5454
}
55-
55+
5656
private func build() -> Chain {
5757
return middleware.reduce(root, { (chain: Chain, middleware: Middleware) -> Chain in
5858
return ForwardingChain { action in
5959
middleware.perform(action, chain)
6060
}
6161
})
6262
}
63-
63+
6464
public func add(middleware: Middleware) {
6565
internalQueue.sync {
6666
self.middleware.append(middleware)
6767
self.chain = build()
6868
}
6969
}
70-
70+
7171
public func remove(middleware: Middleware) {
7272
internalQueue.sync {
7373
if let index = self.middleware.firstIndex(where: { middleware.id == $0.id }) {
@@ -76,21 +76,21 @@ final public class Dispatcher {
7676
chain = build()
7777
}
7878
}
79-
79+
8080
public func register(service: Service) {
8181
internalQueue.sync {
8282
self.service.append(service)
8383
}
8484
}
85-
85+
8686
public func unregister(service: Service) {
8787
internalQueue.sync {
8888
if let index = self.service.firstIndex(where: { service.id == $0.id }) {
8989
self.service.remove(at: index)
9090
}
9191
}
9292
}
93-
93+
9494
public func subscribe(priority: Int, tag: String, completion: @escaping (Action) -> Void) -> DispatcherSubscription {
9595
let subscription = DispatcherSubscription(
9696
dispatcher: self,
@@ -100,7 +100,7 @@ final public class Dispatcher {
100100
completion: completion)
101101
return registerInternal(subscription: subscription)
102102
}
103-
103+
104104
public func registerInternal(subscription: DispatcherSubscription) -> DispatcherSubscription {
105105
internalQueue.sync {
106106
if let map = subscriptionMap[subscription.tag, orPut: OrderedSet<DispatcherSubscription>()] {
@@ -109,7 +109,7 @@ final public class Dispatcher {
109109
}
110110
return subscription
111111
}
112-
112+
113113
public func unregisterInternal(subscription: DispatcherSubscription) {
114114
internalQueue.sync {
115115
var removed = false
@@ -121,13 +121,13 @@ final public class Dispatcher {
121121
assert(removed, "Failed to remove DispatcherSubscription, multiple dispose calls?")
122122
}
123123
}
124-
124+
125125
public func subscribe<T: Action>(completion: @escaping (T) -> Void) -> DispatcherSubscription {
126126
return subscribe(tag: T.tag, completion: { (action: T) -> Void in
127127
completion(action)
128128
})
129129
}
130-
130+
131131
public func subscribe<T: Action>(tag: String, completion: @escaping (T) -> Void) -> DispatcherSubscription {
132132
return subscribe(tag: tag, completion: { object in
133133
if let action = object as? T {
@@ -137,11 +137,11 @@ final public class Dispatcher {
137137
}
138138
})
139139
}
140-
140+
141141
public func subscribe(tag: String, completion: @escaping (Action) -> Void) -> DispatcherSubscription {
142142
return subscribe(priority: Dispatcher.defaultPriority, tag: tag, completion: completion)
143143
}
144-
144+
145145
public func dispatch(_ action: Action, mode: Dispatcher.DispatchMode.UI) {
146146
switch mode {
147147
case .sync:
@@ -158,7 +158,7 @@ final public class Dispatcher {
158158
}
159159
}
160160
}
161-
161+
162162
private func dispatch(_ action: Action) {
163163
assert(DispatchQueue.isMain)
164164
internalQueue.sync {
@@ -176,21 +176,21 @@ final public class Dispatcher {
176176
}
177177
}
178178
}
179-
179+
180180
private func getNewSubscriptionId() -> Int {
181181
return subscriptionCounter.add(1)
182182
}
183183
}
184184

185185
public final class DispatcherSubscription: Comparable, Disposable {
186-
186+
187187
private let dispatcher: Dispatcher
188188
public let id: Int
189189
private let priority: Int
190190
private let completion: (Action) -> Void
191-
191+
192192
public let tag: String
193-
193+
194194
public init (dispatcher: Dispatcher,
195195
id: Int,
196196
priority: Int,
@@ -202,33 +202,32 @@ public final class DispatcherSubscription: Comparable, Disposable {
202202
self.tag = tag
203203
self.completion = completion
204204
}
205-
205+
206206
public func dispose() {
207207
dispatcher.unregisterInternal(subscription: self)
208208
}
209-
209+
210210
public func on(_ action: Action) {
211211
completion(action)
212212
}
213-
213+
214214
public static func == (lhs: DispatcherSubscription, rhs: DispatcherSubscription) -> Bool {
215215
return lhs.id == rhs.id
216216
}
217-
217+
218218
public static func > (lhs: DispatcherSubscription, rhs: DispatcherSubscription) -> Bool {
219219
return lhs.priority > rhs.priority
220220
}
221-
221+
222222
public static func < (lhs: DispatcherSubscription, rhs: DispatcherSubscription) -> Bool {
223223
return lhs.priority < rhs.priority
224224
}
225-
225+
226226
public static func >= (lhs: DispatcherSubscription, rhs: DispatcherSubscription) -> Bool {
227227
return lhs.priority >= rhs.priority
228228
}
229-
229+
230230
public static func <= (lhs: DispatcherSubscription, rhs: DispatcherSubscription) -> Bool {
231231
return lhs.priority <= rhs.priority
232232
}
233233
}
234-

Sources/MiniSwift/Middleware.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@ public protocol Middleware {
2929
}
3030

3131
public final class ForwardingChain: Chain {
32-
32+
3333
private let next: Next
34-
34+
3535
public var proceed: Next {
3636
return { action in
3737
return self.next(action)
3838
}
3939
}
40-
40+
4141
public init(next: @escaping Next) {
4242
self.next = next
4343
}
4444
}
4545

4646
public final class RootChain: Chain {
47-
47+
4848
private let map: SubscriptionMap
49-
49+
5050
public var proceed: Next {
5151
return { action in
5252
if let set = self.map[action.innerTag] {
@@ -57,7 +57,7 @@ public final class RootChain: Chain {
5757
return action
5858
}
5959
}
60-
60+
6161
public init(map: SubscriptionMap) {
6262
self.map = map
6363
}

Sources/MiniSwift/ReducerGroup.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public protocol Group: Disposable {
2222
}
2323

2424
public class ReducerGroup: Group {
25-
25+
2626
public let disposeBag = CompositeDisposable()
27-
27+
2828
init(_ builder: () -> [Disposable]) {
2929
let disposable = builder()
3030
disposable.forEach { _ = disposeBag.insert($0) }
3131
}
32-
32+
3333
public func dispose() {
3434
disposeBag.dispose()
3535
}

Sources/MiniSwift/Store.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import RxSwift
2020
public protocol StoreType {
2121
associatedtype State: StateType
2222
associatedtype StoreController: Disposable
23-
23+
2424
var state: State { get set }
2525
var dispatcher: Dispatcher { get }
2626
var reducerGroup: ReducerGroup { get }
@@ -52,24 +52,24 @@ extension StoreType {
5252
}
5353

5454
public class Store<State: StateType, StoreController: Disposable>: ObservableType, StoreType {
55-
55+
5656
public typealias Element = State
57-
57+
5858
public typealias State = State
5959
public typealias StoreController = StoreController
60-
60+
6161
public typealias ObjectWillChangePublisher = BehaviorSubject<State>
62-
62+
6363
public var objectWillChange: ObjectWillChangePublisher
64-
64+
6565
private var _initialState: State
6666
public let dispatcher: Dispatcher
6767
private var storeController: StoreController
68-
68+
6969
private let queue = DispatchQueue(label: "atomic state")
70-
70+
7171
private var _state: State
72-
72+
7373
public var state: State {
7474
get {
7575
return _state
@@ -83,11 +83,11 @@ public class Store<State: StateType, StoreController: Disposable>: ObservableTyp
8383
}
8484
}
8585
}
86-
86+
8787
public var initialState: State {
8888
return _initialState
8989
}
90-
90+
9191
public init(_ state: State,
9292
dispatcher: Dispatcher,
9393
storeController: StoreController) {
@@ -98,21 +98,21 @@ public class Store<State: StateType, StoreController: Disposable>: ObservableTyp
9898
self.storeController = storeController
9999
self.state = _initialState
100100
}
101-
101+
102102
public var reducerGroup: ReducerGroup {
103103
return ReducerGroup {
104104
[]
105105
}
106106
}
107-
107+
108108
public func replayOnce() {
109109
objectWillChange.onNext(state)
110110
}
111-
111+
112112
public func reset() {
113113
state = initialState
114114
}
115-
115+
116116
public func subscribe<Observer: ObserverType>(_ observer: Observer) -> Disposable where Observer.Element == Store.Element {
117117
return objectWillChange.subscribe(observer)
118118
}

0 commit comments

Comments
 (0)