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

Implicit id for Router #1

Closed
zsoltk opened this issue Dec 22, 2019 · 3 comments
Closed

Implicit id for Router #1

zsoltk opened this issue Dec 22, 2019 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@zsoltk
Copy link
Owner

zsoltk commented Dec 22, 2019

Right now Router needs an explicit unique id for back stack store/retrieval from parent. It would be nice to make this implicitly without having to ask client code to define id.

@zsoltk zsoltk added enhancement New feature or request help wanted Extra attention is needed labels Dec 22, 2019
@zsoltk zsoltk changed the title Implicit id for BankHandler Implicit id for Router Jan 14, 2020
@mvarnagiris
Copy link

mvarnagiris commented Feb 25, 2020

So if you assume that users will use different sealed class per Router, then you could do something like this:

@Composable
inline fun <reified T: Any> Router(defaultRouting: T, children: @Composable() (BackStack<T>) -> Unit) {
    val contextId = T::class.java.name
    ...
}

Or

@Composable
inline fun <reified T: Any> Router(defaultRouting: T, contextId: String = T::class.java.name, children: @Composable() (BackStack<T>) -> Unit) {
    ...
}

@zsoltk
Copy link
Owner Author

zsoltk commented Feb 26, 2020

That's a great idea, thanks! Opened #8 for it if you'd like to review.

@mvarnagiris
Copy link

Looks good!

@zsoltk zsoltk closed this as completed Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants