ReSwift / ReSwift
Showing 1 of 1 files from the diff.

@@ -17,18 +17,20 @@
Loading
17 17
18 18
    typealias SubscriptionType = SubscriptionBox<State>
19 19
20 -
    private(set) public var state: State! {
20 +
    private(set) var _state: Synchronized<State?> {
21 21
        didSet {
22 22
            subscriptions.forEach {
23 23
                if $0.subscriber == nil {
24 24
                    subscriptions.remove($0)
25 25
                } else {
26 -
                    $0.newValues(oldState: oldValue, newState: state)
26 +
                    $0.newValues(oldState: oldValue.value!, newState: _state.value!)
27 27
                }
28 28
            }
29 29
        }
30 30
    }
31 31
32 +
    public var state: State! { _state.value }
33 +
32 34
    public lazy var dispatchFunction: DispatchFunction! = createDispatchFunction()
33 35
34 36
    private var reducer: Reducer<State>
@@ -68,10 +70,9 @@
Loading
68 70
        self.subscriptionsAutomaticallySkipRepeats = automaticallySkipsRepeats
69 71
        self.reducer = reducer
70 72
        self.middleware = middleware
73 +
        self._state = .init(state)
71 74
72 -
        if let state = state {
73 -
            self.state = state
74 -
        } else {
75 +
        if state == nil {
75 76
            dispatch(ReSwiftInit())
76 77
        }
77 78
    }
@@ -166,10 +167,10 @@
Loading
166 167
        }
167 168
168 169
        isDispatching.value { $0 = true }
169 -
        let newState = reducer(action, state)
170 +
        let newState = reducer(action, _state.value)
170 171
        isDispatching.value { $0 = false }
171 172
172 -
        state = newState
173 +
        _state.value { $0 = newState }
173 174
    }
174 175
175 176
    open func dispatch(_ action: Action) {
Files Coverage
ReSwift 98.86%
Project Totals (6 files) 98.86%
1135.3
default=
TRAVIS_OS_NAME=osx
1135.2
default=
TRAVIS_OS_NAME=osx
1135.6
default=
TRAVIS_OS_NAME=osx
1135.4
default=
TRAVIS_OS_NAME=osx
1135.7
default=
TRAVIS_OS_NAME=osx
1
ignore:
2
  - "ReSwiftTests"
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading