Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builders are not properly "saved" when nested types with the same last component are used #3

Closed
zeusent opened this issue Jun 27, 2022 · 3 comments

Comments

@zeusent
Copy link

zeusent commented Jun 27, 2022

For example take these two structures:

struct Section {

    struct Item {
        ...
    }

    var items: [Section.Item]

}

struct SomeOtherTypeWithNestedItemStruct {

    struct Item {
        ...
    }

    var items: [SomeOtherTypeWithNestedItemStruct.Item]

}

If you later use the two Item structs as types for nbNavigationDestination they will override each other's builders and linking will fail:

NBNavigationStack(path: $somePathBinding) {
    SomeView()
        .nbNavigationDestination(for: Section.Item.self, destination: { item in
            SomeItemView(item: item)
        })
        .nbNavigationDestination(for: SomeOtherTypeWithNestedItemStruct.Item.self) { item in
            AnotherItemView(item: item)
        }
}
@zeusent
Copy link
Author

zeusent commented Jun 27, 2022

Maybe try builders[String(reflecting: T.self)] instead of builders["\(T.self)"] to store those builders...

@johnpatrickmorgan
Copy link
Owner

Thanks for finding this issue @zeusent, and for the suggested change. It looks like the best approach, I'll make the necessary changes...

@johnpatrickmorgan
Copy link
Owner

Released in v0.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants