]> git.r.bdr.sh - rbdr/map/blame - Map/State/Store.swift
Release 1.1.0
[rbdr/map] / Map / State / Store.swift
CommitLineData
5e8ff485
RBR
1import Foundation
2
3final class Store<State, Action>: ObservableObject {
4 @Published private(set) var state: State
5
6 private let reducer: Reducer<State, Action>
7
8 init(initialState: State, reducer: @escaping Reducer<State, Action>) {
9 self.state = initialState
10 self.reducer = reducer
11 }
12
13 func send(_ action: Action) {
14 reducer(&state, action)
15 }
16}
17
18typealias Reducer<State, Action> = (inout State, Action) -> Void