aboutsummaryrefslogtreecommitdiff
path: root/Map/State/Store.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Map/State/Store.swift')
-rw-r--r--Map/State/Store.swift18
1 files changed, 18 insertions, 0 deletions
diff --git a/Map/State/Store.swift b/Map/State/Store.swift
new file mode 100644
index 0000000..7860f33
--- /dev/null
+++ b/Map/State/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