Skip to content

[firebase-database] Unsubscribe to event doesn't work #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
danouche93 opened this issue Aug 2, 2022 · 3 comments
Closed

[firebase-database] Unsubscribe to event doesn't work #109

danouche93 opened this issue Aug 2, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@danouche93
Copy link

I use nativescript 8.2.3 with angular and with firebase-database the off function to unsubscribe of events does not seem not work.

listenerWrappers: any[] = [];
EventListener(onValueEvent: any, path: string): any {
    const listener = firebase().database().ref(path).on('value', onValueEvent);
    this.listenerWrappers.push({ listener: listener, path: path });
  }

RemoveListeners(path: string) {
    var listenerWrapper = this.listenerWrappers.filter(l => l.path == path)[0];
    if (listenerWrapper) {
      firebase().database().ref(path).off('value', listenerWrapper.listener)
      this.listenerWrappers.splice(this.listenerWrappers.indexOf(listenerWrapper), 1);
    }
  }

Here how my code looks like. I call the RemoveListeners in my ngOnDestroy function of my component, I have no errors but the event is still attached as I still get log from my callback function.

package.json

{
  "name": "TinaAppV2",
  "main": "./src/main.ts",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@angular/animations": "~13.2.0",
    "@angular/common": "~13.2.0",
    "@angular/compiler": "~13.2.0",
    "@angular/core": "~13.2.0",
    "@angular/forms": "~13.2.0",
    "@angular/platform-browser": "~13.2.0",
    "@angular/platform-browser-dynamic": "~13.2.0",
    "@angular/router": "~13.2.0",
    "@nativescript-community/ui-material-floatingactionbutton": "^7.0.25",
    "@nativescript-community/ui-material-tabs": "^7.0.25",
    "@nativescript-community/ui-pulltorefresh": "^2.5.1",
    "@nativescript/angular": "^13.0.0",
    "@nativescript/core": "~8.2.2",
    "@nativescript/datetimepicker": "^2.1.9",
    "@nativescript/firebase-core": "^2.2.3",
    "@nativescript/firebase-crashlytics": "^2.2.3",
    "@nativescript/firebase-database": "^2.2.3",
    "@nativescript/firebase-messaging": "^2.2.3",
    "@nativescript/firebase-messaging-core": "^2.2.3",
    "@nativescript/geolocation": "^8.0.2",
    "@nativescript/iqkeyboardmanager": "^2.0.0",
    "@nativescript/mlkit-barcode-scanning": "^1.0.5",
    "@nativescript/mlkit-core": "^1.0.5",
    "@nativescript/theme": "~3.0.2",
    "nativescript-forgm-sound": "^1.1.3",
    "nativescript-ui-chart": "^9.0.2",
    "nativescript-ui-sidedrawer": "^10.0.2",
    "rxjs": "~7.5.0",
    "zone.js": "~0.11.5"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^13.3.6",
    "@angular/compiler-cli": "~13.2.0",
    "@nativescript/android": "8.2.2",
    "@nativescript/ios": "8.2.3",
    "@nativescript/types": "~8.2.0",
    "@nativescript/webpack": "~5.0.6",
    "@ngtools/webpack": "~13.2.0",
    "typescript": "~4.5.5"
  }
}
@triniwiz triniwiz added the bug Something isn't working label Aug 3, 2022
@danouche93
Copy link
Author

Any news about this? I have to publish my app and I can't if this isn't fixed, I have a lot of listeners I'm afraid it might crash my app at some point. @triniwiz

@danouche93
Copy link
Author

I updated the plugin, unfortunately, the issue still remains :( @triniwiz

@danouche93
Copy link
Author

if this can be useful, it seems that __classPrivateFieldGet(this, _Query_handles, "f").has(callback) always seems to return false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants