<commit_before>import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import {
  MarvelService,
  MRSService,
  ComicDataWrapper,
  UserData,
  Comic
} from '../shared';

import { ComicsListComponent } from '../comics/list';
@Component({
  selector: 'mrs-library',
  template: require('./library.component.html'),
  styles: [require('./library.component.scss')],
  directives: [ComicsListComponent]
})
export class LibraryComponent implements OnInit {
  elements: any[] = [];

  constructor(
    private _marvelService: MarvelService,
    private _mrsService: MRSService
  ) {}

  ngOnInit(): void {
    this._marvelService.getComics()
      .subscribe((res: ComicDataWrapper) =>
        this.elements = res.data.results
      );

    this._mrsService.userData
      .subscribe((data: UserData) =>
        this.elements.map(element =>
          element.isInCollection = data.comics.has(element.id)
        )
      );
  }

  addComicToCollection(comic) {
    this._mrsService.addComic(comic);
  }

  removeComicFromCollection(comic) {
    this._mrsService.removeComic(comic);
  }
}<commit_msg>Elements in Collection check should listen on both MRS and Marvel services<commit_after>import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import {
  MarvelService,
  MRSService,
  ComicDataWrapper,
  UserData,
  Comic
} from '../shared';

import { ComicsListComponent } from '../comics/list';
@Component({
  selector: 'mrs-library',
  template: require('./library.component.html'),
  styles: [require('./library.component.scss')],
  directives: [ComicsListComponent]
})
export class LibraryComponent implements OnInit {
  elements: any[] = [];
  userData: UserData;

  constructor(
    private _marvelService: MarvelService,
    private _mrsService: MRSService
  ) {}

  ngOnInit(): void {
    this._marvelService.getComics()
      .subscribe((res: ComicDataWrapper) => {
        this.elements = res.data.results;
        this.checkCollectionElements(this.elements, this.userData);
      });

    this._mrsService.userData
      .subscribe((data: UserData) => {
        this.userData = data;
        this.checkCollectionElements(this.elements, this.userData);
      });
  }

  checkCollectionElements(elements, collection) {
    this.elements.map(element => {
      element.isInCollection = collection.comics.has(element.id)
    })
  }

  addComicToCollection(comic) {
    this._mrsService.addComic(comic);
  }

  removeComicFromCollection(comic) {
    this._mrsService.removeComic(comic);
  }
}
{'fraction_non_alphanumeric': 0.13116679718089272, 'fraction_numerical': 0.0, 'mean_word_length': 3.628623188405797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2998964', 'n_tokens_mistral': 797, 'n_tokens_neox': 782, 'n_words': 143}