-
Notifications
You must be signed in to change notification settings - Fork 343
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
Whats the correct way for lazy Router? #559
Comments
I would use the same router of the root/default container. The pin code screen could be shown as a controller with a changehandler that doesn't remove the 'from' view |
Not a great solution, as you need extra code to prevent somebody accidentally pushing a controller on top of pin. New router is safe I think |
You can pass null as saved state. Our is this not an option for you as it will skip restoring a backstack? |
I generally use an extension function for Router to push controllers with standard rules/transitions Maybe you can do something similar // Implemented by every controller related to pin code feature
interface PinCodeRoute
// the controller must implement PinCodeRoute if the latest pushed controller did
fun Router.pushWithStandardRules(controller): Boolean |
Yea exactly, if use is using the pincode and it was displayed, it wont get restored |
We have some apps which use pin code, and we still are passing null to avoid restoring backstack, because we configure it ourselves. Basically, for pin code we store a flag between launches which is then used on app start to determine which controller should be the first one — pin code or some other one. |
@dimsuz right, but you still need to call Conductor.attachRouter in onCreate after rotation happened, otherwise controller will disappear from the router after rotation. Btw do you use single router or have a separate router for pincode controller? |
Here is what I ended up with, using a static member, its ugly but works
|
@ursusursus we don't handle rotation, lock orientation to portrait (runs away and hides in bushes). We use a single router for the whole app. |
Hi, I have a layer in the UI that is only used rarely (pin code feature). I implemented it via new controller container above the "default" controller container.
Now I'd like to lazily initialize the Router, however it takes the savedInstanceState, and I presume its designed to be called in onCreate, not lazily anywhere for example in onResume
Has anyone encountered this? Is it worth avoiding at all? I'd also like to use ViewStub for best optimization however, its pointless if Router needs to be created in onCreate where savedState is accessible
The text was updated successfully, but these errors were encountered: