Showing 1 of 3 files from the diff.

@@ -29,7 +29,7 @@
Loading
29 29
        }
30 30
    }
31 31
32 -
    public var dispatchFunction: DispatchFunction!
32 +
    public lazy var dispatchFunction: DispatchFunction! = createDispatchFunction()
33 33
34 34
    private var reducer: Reducer<State>
35 35
@@ -41,6 +41,12 @@
Loading
41 41
    /// by default.
42 42
    fileprivate let subscriptionsAutomaticallySkipRepeats: Bool
43 43
44 +
    public var middleware: [Middleware<State>] {
45 +
        didSet {
46 +
            dispatchFunction = createDispatchFunction()
47 +
        }
48 +
    }
49 +
44 50
    /// Initializes the store with a reducer, an initial state and a list of middleware.
45 51
    ///
46 52
    /// Middleware is applied in the order in which it is passed into this constructor.
@@ -61,9 +67,18 @@
Loading
61 67
    ) {
62 68
        self.subscriptionsAutomaticallySkipRepeats = automaticallySkipsRepeats
63 69
        self.reducer = reducer
70 +
        self.middleware = middleware
64 71
72 +
        if let state = state {
73 +
            self.state = state
74 +
        } else {
75 +
            dispatch(ReSwiftInit())
76 +
        }
77 +
    }
78 +
79 +
    private func createDispatchFunction() -> DispatchFunction! {
65 80
        // Wrap the dispatch function with all middlewares
66 -
        self.dispatchFunction = middleware
81 +
        return middleware
67 82
            .reversed()
68 83
            .reduce(
69 84
                { [unowned self] action in
@@ -75,12 +90,6 @@
Loading
75 90
                    let getState = { [weak self] in self?.state }
76 91
                    return middleware(dispatch, getState)(dispatchFunction)
77 92
            })
78 -
79 -
        if let state = state {
80 -
            self.state = state
81 -
        } else {
82 -
            dispatch(ReSwiftInit())
83 -
        }
84 93
    }
85 94
86 95
    fileprivate func _subscribe<SelectedState, S: StoreSubscriber>(
Files Coverage
ReSwift 99.48%
Project Totals (6 files) 99.48%
1057.1
default=
TRAVIS_OS_NAME=osx
1057.2
default=
TRAVIS_OS_NAME=osx
1057.5
default=
TRAVIS_OS_NAME=osx
1057.3
default=
TRAVIS_OS_NAME=osx
1057.6
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