diff options
Diffstat (limited to 'Map/Data/Store.swift')
| -rw-r--r-- | Map/Data/Store.swift | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Map/Data/Store.swift b/Map/Data/Store.swift new file mode 100644 index 0000000..7860f33 --- /dev/null +++ b/Map/Data/Store.swift @@ -0,0 +1,18 @@ +import Foundation + +final class Store<State, Action>: ObservableObject { + @Published private(set) var state: State + + private let reducer: Reducer<State, Action> + + init(initialState: State, reducer: @escaping Reducer<State, Action>) { + self.state = initialState + self.reducer = reducer + } + + func send(_ action: Action) { + reducer(&state, action) + } +} + +typealias Reducer<State, Action> = (inout State, Action) -> Void |