Skip to content

Commit 7469a84

Browse files
committed
selector update extensions
1 parent 448f67d commit 7469a84

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

Samples/AnimalsUI/Sources/AnimalsUI/Select.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,40 @@ extension ImmutableUI.Selector {
6666
}
6767
}
6868

69+
extension ImmutableUI.Selector {
70+
mutating func update(
71+
id: some Hashable,
72+
label: String? = nil,
73+
filter isIncluded: (@Sendable (Store.State, Store.Action) -> Bool)? = nil,
74+
dependencySelector: repeat @escaping @Sendable (Store.State) -> each Dependency,
75+
outputSelector: @escaping @Sendable (Store.State) -> Output
76+
) where Store == ImmutableData.Store<AnimalsState, AnimalsAction>, repeat each Dependency : Equatable, Output : Equatable {
77+
self.update(
78+
id: id,
79+
label: label,
80+
filter: isIncluded,
81+
dependencySelector: repeat DependencySelector(select: each dependencySelector),
82+
outputSelector: OutputSelector(select: outputSelector)
83+
)
84+
}
85+
}
86+
87+
extension ImmutableUI.Selector {
88+
mutating func update(
89+
label: String? = nil,
90+
filter isIncluded: (@Sendable (Store.State, Store.Action) -> Bool)? = nil,
91+
dependencySelector: repeat @escaping @Sendable (Store.State) -> each Dependency,
92+
outputSelector: @escaping @Sendable (Store.State) -> Output
93+
) where Store == ImmutableData.Store<AnimalsState, AnimalsAction>, repeat each Dependency : Equatable, Output : Equatable {
94+
self.update(
95+
label: label,
96+
filter: isIncluded,
97+
dependencySelector: repeat DependencySelector(select: each dependencySelector),
98+
outputSelector: OutputSelector(select: outputSelector)
99+
)
100+
}
101+
}
102+
69103
@MainActor @propertyWrapper struct SelectCategoriesValues: DynamicProperty {
70104
@ImmutableUI.Selector(
71105
label: "SelectCategoriesValues",

Samples/CounterUI/Sources/CounterUI/Select.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,40 @@ extension ImmutableUI.Selector {
6565
}
6666
}
6767

68+
extension ImmutableUI.Selector {
69+
mutating func update(
70+
id: some Hashable,
71+
label: String? = nil,
72+
filter isIncluded: (@Sendable (Store.State, Store.Action) -> Bool)? = nil,
73+
dependencySelector: repeat @escaping @Sendable (Store.State) -> each Dependency,
74+
outputSelector: @escaping @Sendable (Store.State) -> Output
75+
) where Store == ImmutableData.Store<CounterState, CounterAction>, repeat each Dependency : Equatable, Output : Equatable {
76+
self.update(
77+
id: id,
78+
label: label,
79+
filter: isIncluded,
80+
dependencySelector: repeat DependencySelector(select: each dependencySelector),
81+
outputSelector: OutputSelector(select: outputSelector)
82+
)
83+
}
84+
}
85+
86+
extension ImmutableUI.Selector {
87+
mutating func update(
88+
label: String? = nil,
89+
filter isIncluded: (@Sendable (Store.State, Store.Action) -> Bool)? = nil,
90+
dependencySelector: repeat @escaping @Sendable (Store.State) -> each Dependency,
91+
outputSelector: @escaping @Sendable (Store.State) -> Output
92+
) where Store == ImmutableData.Store<CounterState, CounterAction>, repeat each Dependency : Equatable, Output : Equatable {
93+
self.update(
94+
label: label,
95+
filter: isIncluded,
96+
dependencySelector: repeat DependencySelector(select: each dependencySelector),
97+
outputSelector: OutputSelector(select: outputSelector)
98+
)
99+
}
100+
}
101+
68102
@MainActor @propertyWrapper struct SelectValue : DynamicProperty {
69103
@ImmutableUI.Selector(outputSelector: CounterState.selectValue()) var wrappedValue
70104

Samples/QuakesUI/Sources/QuakesUI/Select.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,40 @@ extension ImmutableUI.Selector {
6666
}
6767
}
6868

69+
extension ImmutableUI.Selector {
70+
mutating func update(
71+
id: some Hashable,
72+
label: String? = nil,
73+
filter isIncluded: (@Sendable (Store.State, Store.Action) -> Bool)? = nil,
74+
dependencySelector: repeat @escaping @Sendable (Store.State) -> each Dependency,
75+
outputSelector: @escaping @Sendable (Store.State) -> Output
76+
) where Store == ImmutableData.Store<QuakesState, QuakesAction>, repeat each Dependency : Equatable, Output : Equatable {
77+
self.update(
78+
id: id,
79+
label: label,
80+
filter: isIncluded,
81+
dependencySelector: repeat DependencySelector(select: each dependencySelector),
82+
outputSelector: OutputSelector(select: outputSelector)
83+
)
84+
}
85+
}
86+
87+
extension ImmutableUI.Selector {
88+
mutating func update(
89+
label: String? = nil,
90+
filter isIncluded: (@Sendable (Store.State, Store.Action) -> Bool)? = nil,
91+
dependencySelector: repeat @escaping @Sendable (Store.State) -> each Dependency,
92+
outputSelector: @escaping @Sendable (Store.State) -> Output
93+
) where Store == ImmutableData.Store<QuakesState, QuakesAction>, repeat each Dependency : Equatable, Output : Equatable {
94+
self.update(
95+
label: label,
96+
filter: isIncluded,
97+
dependencySelector: repeat DependencySelector(select: each dependencySelector),
98+
outputSelector: OutputSelector(select: outputSelector)
99+
)
100+
}
101+
}
102+
69103
@MainActor @propertyWrapper struct SelectQuakes: DynamicProperty {
70104
@ImmutableUI.Selector<ImmutableData.Store<QuakesState, QuakesAction>, TreeDictionary<Quake.ID, Quake>> var wrappedValue: TreeDictionary<Quake.ID, Quake>
71105

0 commit comments

Comments
 (0)