You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, everybody.. I apologize in advance for my English, but I will try to describe my case.
MainFeature contains an array of NumbersCollectionFeature:
struct MainFeature: Reducer {
struct State: Equatable {
var collections: IdentifiedArrayOf<NumbersCollectionFeature.State> = []
}
enum Action: Equatable {
case collection(id: NumbersCollectionFeature.State.ID, action: NumbersCollectionFeature.Action)
}
var body: some ReducerOf<Self> {
Reduce { state, action in
return .none
}
.forEach(\.collections, action: /Action.collection(id:action:)) {
NumbersCollectionFeature()
}
}
}
NumbersCollectionFeature in turn contains an array of NumberFeature:
struct NumbersCollectionFeature: Reducer {
struct State: Equatable, Identifiable {
var id = UUID()
var numbers: IdentifiedArrayOf<NumberFeature.State> = []
}
enum Action: Equatable {
case number(id: NumberFeature.State.ID, action: NumberFeature.Action)
}
var body: some ReducerOf<Self> {
Reduce { state, action in
return .none
}
.forEach(\.numbers, action: /Action.number(id:action:)) {
NumberFeature()
}
}
}
NumberFeature is a simple feature:
struct NumberFeature: Reducer {
struct State: Equatable, Identifiable {
let id = UUID()
var number: Int
@BindingState var isFavorite = false
}
enum Action: Equatable, BindableAction {
case binding(BindingAction<State>)
}
var body: some ReducerOf<Self> {
BindingReducer()
Reduce { state, action in
switch action {
case .binding:
return .none
}
}
}
}
And then in MainFeature I need to access all favourite NumberFeatures from all collections and be able toggle off isFavorite and propagate the action back to top.
And here I'm completely confused. I will be appreciated for any help.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, everybody.. I apologize in advance for my English, but I will try to describe my case.
MainFeature contains an array of NumbersCollectionFeature:
NumbersCollectionFeature in turn contains an array of NumberFeature:
NumberFeature is a simple feature:
And then in MainFeature I need to access all favourite NumberFeatures from all collections and be able toggle off
isFavorite
and propagate the action back to top.And here I'm completely confused. I will be appreciated for any help.
Beta Was this translation helpful? Give feedback.
All reactions