All files / src/lib/core ng-bindings.service.ts

33.33% Statements 3/9
0% Branches 0/2
50% Functions 1/2
25% Lines 2/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                              1x         97x                              
import { ChangeDetectorRef, ElementRef, Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
 
export interface RefBindingSubject {
  subject: BehaviorSubject<any>;
  cdRef: ChangeDetectorRef;
  eRef: ElementRef;
}
 
/**
 * A registry for AngularJS binding subjects.
 */
@Injectable({
  providedIn: 'root'
})
export class NgBindingsService {
 
  private readonly subjects: { [key: string]: Array<RefBindingSubject> };
 
  constructor() {
    this.subjects = {};
  }
 
  putSubject(key: string, subject: RefBindingSubject): Array<RefBindingSubject> {
    let subjects = this.subjects[key];
    if (!subjects) {
      subjects = [];
      this.subjects[key] = subjects;
    }
    this.subjects[key].push(subject);
 
    return this.subjects[key];
  }
 
}