Select root view based on some condition

Please forgive it seems a stupid question. I am beginner in Framework7.

Cannot figure out how to set root view on based on some condition.

e.g. If the user is logged in, I would like to present him dashboard, otherwise login screen.

Please provide an example to achieve this.

I achieved similar effect by loading different pages on the condition like:

if (/*USER LOGGED IN*/) {
    //User is already logged in
    mainView.router.navigate('/dashboard/', { animate: false, reloadAll: true });
else {
    //user not logged in
    mainView.router.navigate('/login/', { animate: false, reloadAll: true });
1 Like