Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

IdentifiedArrayOf without ForEach #3659

Unanswered
Alex1478 asked this question in Q&A
Discussion options

I know we can use ForEach to scope over an array of child reducers, like so:

 // ....

@ObservableState
public struct Feature: Equatable {
    var childs: IdentifiedArrayOf<ChildFeature.State> = []

    // ....
}
ForEach(store.scope(state: \.childs, action: \.childs)) { store in
    ChildFeatureView(store: store)
}

Is there a way to cherry-pick a specific reducer from that array by its ID? Something like:

if let store = store.scope(id: childFeatureID, state: \.childs, action: \.childs) {
    ChildFeatureView(store: store)
}

Apologies if this is already covered in the docs or a tutorial—I haven’t come across it yet.
Thanks a ton—TCA really makes development smoother and more enjoyable!

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.