ngx-rocket / generator-ngx-rocket

:rocket: Extensible Angular 14+ enterprise-grade project generator
https://ngx-rocket.github.io/
MIT License
1.53k stars 218 forks source link

UntilDestroyed not working #577

Closed sonyz closed 3 years ago

sonyz commented 3 years ago

I'm submitting a...

Current behavior

The UntilDestroyed on Observable is not working. In the ngOnDestroy(), the method is not called correctly.

Expected behavior

The observable must be "destroyed" when ngOnDestroy is automatically called.

Minimal reproduction of the problem with instructions

ngOnInit(): void { let number = Math.floor(Math.random() 100); // Init scheduled calls to operation statuses interval(5 1000) .pipe(startWith(0)) .pipe(untilDestroyed(this)) .subscribe(() => { console.log('test', number); }); }

ngOnDestroy(): void { console.log('destroyed'); }

The 'destroyed' log is correctly displayed but the observable still exists.

Environment



ngX-Rocket: 9.1.0
Node.js: v12.18.3
Npm: 6.14.6
OS: linux x64 5.4.0-53-generic

Generated project options:
{
  "generator-ngx-rocket": {
    "version": "9.1.0",
    "props": {
      "location": "path",
      "strict": false,
      "skipInstall": false,
      "skipQuickstart": false,
      "initGit": true,
      "usePrefix": true,
      "appName": "app-ui",
      "target": [
        "web"
      ],
      "pwa": false,
      "ui": "bootstrap",
      "auth": true,
      "lazy": false,
      "angulartics": false,
      "languages": [
        "en-US",
        "fr-FR"
      ],
      "tools": [
        "prettier"
      ],
      "utility": [],
      "deploy": "none",
      "projectName": "app-ui",
      "packageManager": "npm",
      "mobile": [],
      "desktop": []
    }
  }
}

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 10.1.7
Node: 12.18.3
OS: linux x64

Angular: 10.2.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1001.7
@angular-devkit/build-angular   0.1001.7
@angular-devkit/core            10.1.7
@angular-devkit/schematics      10.1.7
@angular/cli                    10.1.7
@schematics/angular             10.1.7
@schematics/update              0.1001.7
rxjs                            6.6.3
typescript                      4.0.3

Others:

luiza-cicone commented 3 years ago

I had the same problem on an app after migrating to Angular 9 (if I am not mistaken). @sinedied wdyt of using the ngneat/until-destroy plugin?

sonyz commented 3 years ago

I think the workaround is to add the dependency to this plugin and to not use the until-destroy in the package for moment.

sinedied commented 3 years ago

@luiza-cicone when I wrote the initial version of untilDestroyed, the available version of until-destroy package has some issues, and it fell dumb to add a dependency for a few lines of codes. But it seems that it's now more complex than that with the new Ivy engine, so it's time to migrate and use the better version 👍

ci-rebot commented 3 years ago

:tada: This issue has been resolved in version 9.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: