[BANanoVuetifyAD3] Introducing the beforeEnter Router Event...

Mashiane

Expert
Licensed User
Longtime User
Hi

B4X:
Sub beforeEnter(boTo As Map, boFrom As Map, boNext As BANanoObject)
    'the page we are going to
    vuetify.SaveRoute(boTo, False)
    'check authentication
    If vuetify.Authenticated = False Then
        'user is not authenticated, go to login page
        vuetify.NavigateToNext(boNext, "login")
        Return
    End If
    'continue navigation
    vuetify.NavigateToNext(boNext, "")
End Sub

At times you want to perform something before a page enteres the UI. In most cases one will use the created (fetchData) and mounted (updateUI) life cycle events. However there is another gem, that is being explored in BVAD3, the beforeEnter router event. This happens before your page enteres.

1. You can check if a user is authenticated and if not navigate them to the login page. This is what the code above does.
2. Show a loading dialog (this has not been explored on time of this post)
3. Some other wishful things...

Have fun!

PS: All the b4xTemplates will be updated with this block of code, commented.

 
Top