Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
410 views
in Technique[技术] by (71.8m points)

javascript - Firebase stop listening onAuthStateChanged

As of version ^3.0.0, I'm having a difficult time removing the auth state change listener.

To start the listener per the documentation:

firebase.auth().onAuthStateChanged(function (user) {
    // handle it
});

However, I cannot find anywhere in the documentation that refers to a remove auth state change listener. There is peculiar function on the Firebase.Auth class called removeAuthTokenListener. Unfortunately it's not documented (firebase docs reference).

Via your browser's web console.

var auth = firebase.auth();
auth.removeAuthTokenListener;

prints a function definition that takes one parameter. I tried to do the following:

this.authListener = firebase.auth().onAuthStateChanged(function (user) {...});
firebase.auth().removeAuthTokenListener(this.authListener);

but that didn't do anything.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...