Firebase stop listening onAuthStateChanged

后端 未结 2 584
遇见更好的自我
遇见更好的自我 2020-12-02 19:56

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.a         


        
2条回答
  •  旧巷少年郎
    2020-12-02 20:14

    According to the documentation, the onAuthStateChanged() function returns

    The unsubscribe function for the observer.

    So you can just:

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

    And then:

    unsubscribe();
    

提交回复
热议问题