Project

General

Profile

« Previous | Next » 

Revision 59816

[Library|Trunk]

code clean up:
-remove app.* files from library
-remove unused imports, code, files (Old search pages for results, dataproviders, map search page, etc)
-remove Freeguard from modules
-unsubscribe all subscriptions
-Services: configuration, isvocabularies, user management: unsubscribe from app component or the component that uses them (clearSubscriptions())
-Fetchers: unsubscribe from the component that uses them (clearSubscriptions())

View differences:

userMini.component.ts
1
import {Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
1
import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
2 2
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
3
import {Location} from '@angular/common';
4 3
import {User, Session} from './utils/helper.class';
5 4
import {RouterHelper} from '../utils/routerHelper.class';
6 5
import {StringUtils} from '../utils/string-utils.class';
7
import {EnvProperties} from '../utils/properties/env-properties';
8 6
import {properties} from "../../../environments/environment";
7
import {Subscriber} from "rxjs";
9 8

  
10 9
// declare var logoutClicked;
11 10
@Component({
......
180 179
  @Input() redirectUrl: string;
181 180
  @Input() dark: boolean = false;
182 181
  search: string = '';
183
  sub: any;
182
  subscriptions = [];
184 183
  
185 184
  constructor(private router: Router, private  route: ActivatedRoute) {
186
    this.router.events.forEach(event => {
185
    this.subscriptions.push(this.router.events.forEach(event => {
187 186
      if (event instanceof NavigationStart) {
188 187
        this.initialize(event.url);
189 188
      }
190
    });
189
    }));
191 190
  }
192 191
  
193 192
  ngOnInit() {
194 193
    if (typeof document !== 'undefined') {
195 194
      this.server = false;
196 195
    }
197
    this.sub = this.route.queryParams.subscribe(params => {
196
    this.subscriptions.push(this.route.queryParams.subscribe(params => {
198 197
      this.initialize();
199
    });
198
    }));
200 199
  }
201 200
  
202 201
  ngOnChanges(changes: SimpleChanges): void {
......
204 203
      this.initialize();
205 204
    }
206 205
  }
207
  
206

  
208 207
  ngOnDestroy() {
209
    if (this.sub) {
210
      this.sub.unsubscribe();
211
    }
208
    this.subscriptions.forEach(subscription => {
209
      if (subscription instanceof Subscriber) {
210
        subscription.unsubscribe();
211
      }
212
    });
212 213
  }
213 214
  
214 215
  initialize(url: string = null) {

Also available in: Unified diff