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:

claimContextSearchForm.component.ts
1 1
import {Component, Input} from '@angular/core';
2 2
import {Router} from '@angular/router';
3 3
import {ContextsService} from './service/contexts.service';
4
import {ClaimContext, ClaimEntity} from './claimHelper.class';
4
import {ClaimEntity} from './claimHelper.class';
5 5
import {Session} from '../../login/utils/helper.class';
6 6
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
7 7
import {EnvProperties} from '../../utils/properties/env-properties';
8
import {Subscriber} from "rxjs";
8 9

  
9 10
declare var UIkit: any;
10 11

  
......
39 40
  @Input() localStoragePrefix: string = "";
40 41

  
41 42
  keyword = "";
42

  
43
  subscriptions = [];
43 44
  ngOnInit() {
44 45
    this.getCommunities();
45 46
  }
46

  
47
  ngOnDestroy() {
48
    this.subscriptions.forEach(subscription => {
49
      if (subscription instanceof Subscriber) {
50
        subscription.unsubscribe();
51
      }
52
    });
53
  }
47 54
  constructor(private _contextService: ContextsService, private router: Router) {
48 55

  
49 56
  }
......
114 121

  
115 122
    } else {
116 123
      this.loading = true;
117
      this._contextService.getPublicCommunitiesByState().subscribe(
124
      this.subscriptions.push(this._contextService.getPublicCommunitiesByState().subscribe(
118 125
        data => {
119 126
          this.communities = data;
120 127
          if (this.communities.length > 0) {
......
143 150
          this.loading = false;
144 151
          this.error = true;
145 152
        }
146
      );
153
      ));
147 154
    }
148 155
  }
149 156

  
......
160 167
          this.loading = false;
161 168
          return;
162 169
        }
163
        this._contextService.getCategories(this.selectedCommunityId, this.properties.contextsAPI).subscribe(
170
        this.subscriptions.push(this._contextService.getCategories(this.selectedCommunityId, this.properties.contextsAPI).subscribe(
164 171
          data => {
165 172

  
166 173
            this.categories[this.selectedCommunityId] = data;
......
176 183
            ClaimContextSearchFormComponent.handleError("Error getting categories for community with id: " + this.selectedCommunityId, err);
177 184
            this.loading = false;
178 185
          }
179
        );
186
        ));
180 187
      }
181 188
    }
182 189
  }
......
272 279
      }
273 280
      this.conceptsClass[categoryId] = [];
274 281
      this.conceptsCategoryLoading[categoryId] = true;
275
      this._contextService.getConcepts(categoryId, "", false, this.properties.contextsAPI).subscribe(
282
      this.subscriptions.push(this._contextService.getConcepts(categoryId, "", false, this.properties.contextsAPI).subscribe(
276 283
        data => {
277 284
          // var concepts = data;
278 285
          this.conceptsClass[categoryId] = [];
......
290 297
          ClaimContextSearchFormComponent.handleError("Error getting concepts for category with id: " + this.selectedCategoryId, err);
291 298
          this.conceptsCategoryLoading[categoryId] = false;
292 299
        }
293
      );
300
      ));
294 301
    }
295 302

  
296 303
  }
......
298 305
  browseSubConcepts(categoryId, conceptId) {
299 306

  
300 307
    this.conceptsCategoryLoading[categoryId] = true;
301
    this._contextService.getSubConcepts(conceptId, "", false, this.properties.contextsAPI).subscribe(
308
    this.subscriptions.push(this._contextService.getSubConcepts(conceptId, "", false, this.properties.contextsAPI).subscribe(
302 309
      data => {
303 310
        const concepts = data[0];
304 311
        this.conceptsClass[categoryId].push(concepts);
......
309 316
        ClaimContextSearchFormComponent.handleError("Error getting subconcepts for concept with id: " + conceptId, err);
310 317
        this.conceptsCategoryLoading[categoryId] = false;
311 318
      }
312
    );
319
    ));
313 320

  
314 321

  
315 322
  }

Also available in: Unified diff