I like using cacheViews:true in my application...

I've made a SPA app with logout/login. Some views I have them render different views based on whether or not the current user is an administrator using the 'viewUrl' (HotTowel Durandal Inject different views based on the user)

The problem I'm having is that if you logout of an administrator account and into a normal user account all the previous views are cached so as you navigate around it brings up all the admin views (the different viewmodels activate functions aren't running)

I'm looking for an easy way to reset all these views/viewmodels when you press the logout button so the app 'starts fresh' when the next user logs in.

有帮助吗?

解决方案

It's a single page application, so reloading it on logout by using window.location.reload() will make the app 'start fresh'.

With that said make sure to profile memory consumption of the app, when cacheViews: true. As long as the cached views stay in the DOM, garbage collection won't be able to reallocate memory.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top