27 lines
614 B
TypeScript
27 lines
614 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import {Observable, Subject} from 'rxjs';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class ArrayInputHelperService {
|
|
|
|
com: Subject<{ id: string, index: number, value: any }> = new Subject();
|
|
|
|
constructor() { }
|
|
|
|
values(id: string) {
|
|
return new Observable<{index: number, value: any}>(observer => {
|
|
this.com.subscribe(data => {
|
|
if (data.id === id) {
|
|
observer.next({index: data.index, value: data.value});
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
newValue(id: string, index: number, value: any) {
|
|
this.com.next({id, index, value});
|
|
}
|
|
}
|