@@ -42,6 +42,10 @@ export default class BranchSubscriber {
4242 if ( 'checkCachedEvents' in this . options ) {
4343 this . _checkCachedEvents = this . options . checkCachedEvents
4444 }
45+
46+ this . initSessionStart = null
47+ this . initSessionSuccess = null
48+ this . initSessionError = null
4549 }
4650
4751 subscribe ( ) {
@@ -96,12 +100,12 @@ export default class BranchSubscriber {
96100 */
97101 _subscribe ( ) {
98102 if ( this . options . onOpenStart ) {
99- this . _nativeEventEmitter . addListener ( RNBranch . INIT_SESSION_START , this . options . onOpenStart )
103+ this . initSessionStart = this . _nativeEventEmitter . addListener ( RNBranch . INIT_SESSION_START , this . options . onOpenStart )
100104 }
101105
102106 if ( this . options . onOpenComplete ) {
103- this . _nativeEventEmitter . addListener ( RNBranch . INIT_SESSION_SUCCESS , this . options . onOpenComplete )
104- this . _nativeEventEmitter . addListener ( RNBranch . INIT_SESSION_ERROR , this . options . onOpenComplete )
107+ this . initSessionSuccess = this . _nativeEventEmitter . addListener ( RNBranch . INIT_SESSION_SUCCESS , this . options . onOpenComplete )
108+ this . initSessionError = this . _nativeEventEmitter . addListener ( RNBranch . INIT_SESSION_ERROR , this . options . onOpenComplete )
105109 }
106110 }
107111
@@ -114,12 +118,12 @@ export default class BranchSubscriber {
114118 this . _subscribed = false
115119
116120 if ( this . options . onOpenStart ) {
117- this . _nativeEventEmitter . removeListener ( RNBranch . INIT_SESSION_START , this . options . onOpenStart )
121+ this . initSessionStart . remove ( )
118122 }
119123
120124 if ( this . options . onOpenComplete ) {
121- this . _nativeEventEmitter . removeListener ( RNBranch . INIT_SESSION_SUCCESS , this . options . onOpenComplete )
122- this . _nativeEventEmitter . removeListener ( RNBranch . INIT_SESSION_ERROR , this . options . onOpenComplete )
125+ this . initSessionSuccess . remove ( )
126+ this . initSessionError . remove ( )
123127 }
124128 }
125129}
0 commit comments