Kotlin: Listen to auth events

Listen to session changes.

Examples

Listen to auth changes

supabase.auth.sessionStatus.collect \{
    when(it) \{
        is SessionStatus.Authenticated -> \{
            println("Received new authenticated session.")
            when(it.source) \{ //Check the source of the session
                SessionSource.External -> TODO()
                is SessionSource.Refresh -> TODO()
                is SessionSource.SignIn -> TODO()
                is SessionSource.SignUp -> TODO()
                SessionSource.Storage -> TODO()
                SessionSource.Unknown -> TODO()
                is SessionSource.UserChanged -> TODO()
                is SessionSource.UserIdentitiesChanged -> TODO()
            \}
        \}
        SessionStatus.LoadingFromStorage -> println("Loading from storage")
        SessionStatus.NetworkError -> println("Network error")
        is SessionStatus.NotAuthenticated -> \{
            if(it.isSignOut) \{
                println("User signed out")
            \} else \{
                println("User not signed in")
            \}
        \}
    \}
\}