Skip to content

Commit

Permalink
feat: migrate to @ngneat/until-destroy (fix #577)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Jan 12, 2021
1 parent 1cb9280 commit 937055c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 240 deletions.
1 change: 1 addition & 0 deletions generators/app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
"@biesbjerg/ngx-translate-extract": "^7.0.3",
"@biesbjerg/ngx-translate-extract-marker": "^1.0.0",
"@ngx-rocket/scripts": "^5.0.0",
"@ngneat/until-destroy": "^8.0.3",
"@types/jasmine": "^3.6.2",
"@types/jasminewd2": "^2.0.8",
<% if (props.tools.includes('jest')) { -%>
Expand Down
2 changes: 1 addition & 1 deletion generators/app/templates/src/app/@core/_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export * from './http/api-prefix.interceptor';
export * from './http/error-handler.interceptor';
export * from './route-reusable-strategy';
export * from './logger.service';
export * from './until-destroyed';
export * from '@ngneat/until-destroy';;
165 changes: 0 additions & 165 deletions generators/app/templates/src/app/@core/until-destroyed.spec.ts

This file was deleted.

62 changes: 0 additions & 62 deletions generators/app/templates/src/app/@core/until-destroyed.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
<% if (props.ui === 'ionic') { -%>
Expand All @@ -9,17 +9,18 @@ import { forkJoin, from } from 'rxjs';
import { finalize } from 'rxjs/operators';

import { environment } from '@env/environment';
import { Logger, untilDestroyed } from '@core';
import { Logger, UntilDestroy, untilDestroyed } from '@core';
import { AuthenticationService } from './authentication.service';

const log = new Logger('Login');

@UntilDestroy()
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit, OnDestroy {
export class LoginComponent implements OnInit {

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

ngOnInit() { }

ngOnDestroy() { }

<% if (props.ui === 'ionic') { -%>
async login() {
<% } else { -%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { Component, OnInit, ViewChild } from '@angular/core';
import { MediaChange, MediaObserver } from '@angular/flex-layout';
import { MatSidenav } from '@angular/material/sidenav';
import { filter } from 'rxjs/operators';

import { untilDestroyed } from '@core';
import { UntilDestroy, untilDestroyed } from '@core';

@UntilDestroy()
@Component({
selector: 'app-shell',
templateUrl: './shell.component.html',
styleUrls: ['./shell.component.scss']
})
export class ShellComponent implements OnInit, OnDestroy {
export class ShellComponent implements OnInit {

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

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

ngOnDestroy() {
// Needed for automatic unsubscribe with untilDestroyed
}

}

0 comments on commit 937055c

Please sign in to comment.