mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-03-12 21:35:28 +01:00
35 lines
705 B
Swift
Executable File
35 lines
705 B
Swift
Executable File
//
|
|
// AppStore.swift
|
|
// SwiftUIDemo
|
|
//
|
|
// Created by Thomas Ricouard on 05/06/2019.
|
|
// Copyright © 2019 Thomas Ricouarf. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftUI
|
|
import Combine
|
|
|
|
final class AppState: BindableObject {
|
|
var didChange = PassthroughSubject<AppState, Never>()
|
|
|
|
var usersState: UsersState
|
|
|
|
init(usersState: UsersState = UsersState()) {
|
|
self.usersState = usersState
|
|
}
|
|
|
|
func dispatch(action: Action) {
|
|
usersState = UserStateReducer().reduce(state: usersState, action: action)
|
|
didChange.send(self)
|
|
}
|
|
}
|
|
|
|
let store = AppState()
|
|
|
|
#if DEBUG
|
|
let sampleStore = AppState(usersState: UsersState(users: sampleData))
|
|
#endif
|
|
|
|
|