File

projects/wvr-elements/src/lib/core/ng-bindings.service.ts

Description

A registry for AngularJS binding subjects.

Index

Properties
Methods

Constructor

constructor()

Methods

putSubject
putSubject(key: string, subject: RefBindingSubject)
Parameters :
Name Type Optional
key string No
subject RefBindingSubject No

Properties

Private Readonly subjects
Type : literal type
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];
  }

}

results matching ""

    No results matching ""