From 5e8ff4850c4827125fe12788dd5b153c4f636f48 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Wed, 3 Feb 2021 23:53:12 +0100 Subject: Add code for first release --- Map/State/Store.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Map/State/Store.swift (limited to 'Map/State/Store.swift') 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: ObservableObject { + @Published private(set) var state: State + + private let reducer: Reducer + + init(initialState: State, reducer: @escaping Reducer) { + self.state = initialState + self.reducer = reducer + } + + func send(_ action: Action) { + reducer(&state, action) + } +} + +typealias Reducer = (inout State, Action) -> Void -- cgit