File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Sources/ComposableArchitecturePattern Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // ViewCoordinator.swift
3+ // ComposableViewPattern
4+ //
5+ // Created by Jonathan Holland on 3/9/24.
6+ //
7+
8+ import SwiftUI
9+
10+ public protocol ViewCoordinator {
11+ associatedtype ContentView : View
12+ var view : ContentView { get }
13+ var state : ViewCoordinatorState { get }
14+
15+ func load( ) async
16+ func reload( ) async
17+ }
18+
19+ extension ViewCoordinator {
20+ public func load( ) async { }
21+ public func reload( ) async { }
22+ }
23+
24+ public enum ViewCoordinatorState : Equatable {
25+ public static func == ( lhs: ViewCoordinatorState , rhs: ViewCoordinatorState ) -> Bool {
26+ if case let . error( lhsError) = lhs, case let . error( rhsError) = rhs {
27+ return lhsError? . localizedDescription == rhsError? . localizedDescription
28+ } else if case . idle = lhs, case . idle = rhs {
29+ return true
30+ } else if case . loaded = lhs, case . loaded = rhs {
31+ return true
32+ } else if case . needsReload = lhs, case . needsReload = rhs {
33+ return true
34+ }
35+ return false
36+ }
37+
38+ case idle
39+ case loaded
40+ case needsReload
41+ case error( error: Error ? = nil )
42+ }
You can’t perform that action at this time.
0 commit comments