-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdb0ca1
commit 656749e
Showing
6 changed files
with
82 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Created by Emilio Peláez on 18/10/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct DeclaredEventsKey: PreferenceKey { | ||
struct Container { | ||
var events: [any Event.Type] | ||
} | ||
|
||
static var defaultValue: Container = .init(events: []) | ||
|
||
static func reduce(value: inout Container, nextValue: () -> Container) { | ||
value.events.append(contentsOf: nextValue().events) | ||
} | ||
} | ||
|
||
struct DeclaredErrorsKey: PreferenceKey { | ||
struct Container { | ||
var errors: [any Error.Type] | ||
} | ||
|
||
static var defaultValue: Container = .init(errors: []) | ||
|
||
static func reduce(value: inout Container, nextValue: () -> Container) { | ||
value.errors.append(contentsOf: nextValue().errors) | ||
} | ||
} | ||
|
||
extension DeclaredEventsKey.Container: Equatable { | ||
static func == (lhs: DeclaredEventsKey.Container, rhs: DeclaredEventsKey.Container) -> Bool { | ||
lhs.events.map { String(describing: $0) } == rhs.events.map { String(describing: $0) } | ||
} | ||
} | ||
|
||
extension DeclaredErrorsKey.Container: Equatable { | ||
static func == (lhs: DeclaredErrorsKey.Container, rhs: DeclaredErrorsKey.Container) -> Bool { | ||
lhs.errors.map { String(describing: $0) } == rhs.errors.map { String(describing: $0) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters