之前我一直在使用firebase.auth.currentUser
,但当应用程序加载时它给了我null
,而我需要在应用程序加载时立即获得授权用户(或者可以使用回调函数)。然后我决定使用onAuthStateChanged
,但现在我无法取消订阅它,因为它会一遍遍地触发,我只想要它立即提供授权并彻底销毁。
那么,我该如何取消订阅它呢?
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
}
});