Moved stuff around, changed the way I'm storing milestones data
This commit is contained in:
25
src/services/filters.service.ts
Normal file
25
src/services/filters.service.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { KeyValue } from '../models/key-value';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class FilterService {
|
||||
private _values: KeyValue[] = [];
|
||||
private set filters(value: KeyValue[]) {
|
||||
this._values = value;
|
||||
this.filterSubject.next(this._values);
|
||||
}
|
||||
private get filters(): KeyValue[] {
|
||||
return this._values;
|
||||
}
|
||||
private filterSubject = new Subject<KeyValue[]>();
|
||||
readonly filters$ = this.filterSubject.asObservable();
|
||||
|
||||
constructor() {}
|
||||
|
||||
set(key: string, value: any): void {
|
||||
const update = this.filters.filter((f: KeyValue) => f.key !== key);
|
||||
if (!!value) update.push(new KeyValue({ key: key, value: value }));
|
||||
this.filters = update;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user