Skip to content

Commit 3a77fcb

Browse files
committed
feat: migrate to @ngneat/until-destroy (fix #577)
1 parent 64098dc commit 3a77fcb

File tree

6 files changed

+10
-240
lines changed

6 files changed

+10
-240
lines changed

generators/app/templates/_package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
"@biesbjerg/ngx-translate-extract": "^7.0.3",
135135
"@biesbjerg/ngx-translate-extract-marker": "^1.0.0",
136136
"@ngx-rocket/scripts": "^5.0.0",
137+
"@ngneat/until-destroy": "^8.0.3",
137138
"@types/jasmine": "^3.6.2",
138139
"@types/jasminewd2": "^2.0.8",
139140
<% if (props.tools.includes('jest')) { -%>

generators/app/templates/src/app/@core/_index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ export * from './http/api-prefix.interceptor';
33
export * from './http/error-handler.interceptor';
44
export * from './route-reusable-strategy';
55
export * from './logger.service';
6-
export * from './until-destroyed';
6+
export * from '@ngneat/until-destroy';;

generators/app/templates/src/app/@core/until-destroyed.spec.ts

Lines changed: 0 additions & 165 deletions
This file was deleted.

generators/app/templates/src/app/@core/until-destroyed.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

generators/app/templates/src/app/auth/__auth._login.component.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit, OnDestroy } from '@angular/core';
1+
import { Component, OnInit } from '@angular/core';
22
import { Router, ActivatedRoute } from '@angular/router';
33
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
44
<% if (props.ui === 'ionic') { -%>
@@ -9,17 +9,18 @@ import { forkJoin, from } from 'rxjs';
99
import { finalize } from 'rxjs/operators';
1010

1111
import { environment } from '@env/environment';
12-
import { Logger, untilDestroyed } from '@core';
12+
import { Logger, UntilDestroy, untilDestroyed } from '@core';
1313
import { AuthenticationService } from './authentication.service';
1414

1515
const log = new Logger('Login');
1616

17+
@UntilDestroy()
1718
@Component({
1819
selector: 'app-login',
1920
templateUrl: './login.component.html',
2021
styleUrls: ['./login.component.scss']
2122
})
22-
export class LoginComponent implements OnInit, OnDestroy {
23+
export class LoginComponent implements OnInit {
2324

2425
version: string | null = environment.version;
2526
error: string | undefined;
@@ -39,8 +40,6 @@ export class LoginComponent implements OnInit, OnDestroy {
3940

4041
ngOnInit() { }
4142

42-
ngOnDestroy() { }
43-
4443
<% if (props.ui === 'ionic') { -%>
4544
async login() {
4645
<% } else { -%>

generators/app/templates/src/app/shell/__material-simple.shell.component.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
1+
import { Component, OnInit, ViewChild } from '@angular/core';
22
import { MediaChange, MediaObserver } from '@angular/flex-layout';
33
import { MatSidenav } from '@angular/material/sidenav';
44
import { filter } from 'rxjs/operators';
55

6-
import { untilDestroyed } from '@core';
6+
import { UntilDestroy, untilDestroyed } from '@core';
77

8+
@UntilDestroy()
89
@Component({
910
selector: 'app-shell',
1011
templateUrl: './shell.component.html',
1112
styleUrls: ['./shell.component.scss']
1213
})
13-
export class ShellComponent implements OnInit, OnDestroy {
14+
export class ShellComponent implements OnInit {
1415

1516
@ViewChild('sidenav', { static: false }) sidenav!: MatSidenav;
1617

@@ -27,8 +28,4 @@ export class ShellComponent implements OnInit, OnDestroy {
2728
.subscribe(() => this.sidenav.close());
2829
}
2930

30-
ngOnDestroy() {
31-
// Needed for automatic unsubscribe with untilDestroyed
32-
}
33-
3431
}

0 commit comments

Comments
 (0)