-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(uiViewCache): outer most views can now be reused #2333
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
Conversation
Nice. I wanna poke at it a bit to see if I can clean up the code that interacts with ngAnimate, and see if I can figure out a way to at least drop the leaf-nodes-only restriction. It's also gonna take a bit of workshopping to make it 1.0-compatible, since the view layer no longer directly interacts with @christopherthielen I think we should probably just drop 0.2.16 and then feature-freeze 0.2.x. |
I didn't like animation code either, but I though it's best to not remove backwards compatibility (not for me to decide anyway) - Is angular 1.2 still relevant for this library? Regarding leaf-nodes quirks/restriction, it might not be an issue at all if inner views are cleaned up/removed before parent when navigating to a new state. So that cached entry would only have placeholders for inner states. I looked into what goes wrong, but I couldn't figure out exact problem/pattern. No errors are logged to console, view just stays empty or looses interactivity. Other than that, it might be convenient to be able to set persistent flag on per view basis (I can submit another PR at some point or push another commit, let me know if this is of interest to you). Do you have any opinion about handling scroll offset? Should it be be taken care automatically or left for developers to maintain? |
It'd be nice if we could figure out a way to do the 'right' thing by default, but I don't think it's worth holding up the feature over. |
Just an FYI, I've ran into a small issue with viewRestored event. As it is now it is $emitted from controller scope therefore child elements have no clue when it happens. |
Hey, sorry for taking forever to come back on this. Hmm... how would listeners have context for what's happening (i.e. since most views are unnamed)? |
That's a good question... I am not sure if anything else besides view name (more like path) makes sense. Anyway - I worked around the issue described above (couldn't find place in code), I just remember that I needed to reset current state in child directive when view is restored. |
Can't wait to see this cached/persisted thing to be merged......... @FDIM : I have read the your "whole story", your problem is exactly same as mine. How can I get your solution? ( I don't know how to to Git PR , merge , commit , build things :( .. ) |
Ar the moment for my projects I am referencing my own fork. If you are using bower you can simply add 'angular-ui-router': 'https://github.com/FDIM/ui-router/#persistent-view' to use it. #master doesn't include updated dist files, only clean commits for this issue. |
@FDIM : I have managed to download and grunt build your code. It works great but not perfect.
Again, thanks for your contribution |
2 things you mentioned are the downsides of having a cache as you have to handle these cases manually.
|
@FDIM : got you. thanks again |
This issue has been automatically marked as stale because it has not had This does not mean that the issue is invalid. Valid issues Thank you for your contributions. |
This PR resolves #1800 and enables reusable / persistent views. When user navigates to a persistent state it will be exactly as it was before navigating away. This greatly improves user experience if you are targeting mobile apps or have complex elements in page.
By adding 'persistent:true' flag to a state config you indicate that it is reusable. Such states will only be initialized once and through the use of additional events you can control what happens when user revisit same state and control it's lifetime.
There are 2 additional events:
reset
function that will clear cache of this view so that it would be reinitialized next time user navigates to this state.and there are 2 quirks: