import {Tags} from '../../util';
import {Settable} from '../settable';
import {ReadOnlyValue, Value} from './metric';
export class LocalSettable<T> implements Settable<T> {
protected _val: Value<T | undefined>;
constructor(readonly name: string, readonly tags: Tags = {}) {
this._val = new ReadOnlyValue(this.name, undefined, this.tags);
}
get value(): Value<T | undefined> {
return this._val;
}
get raw(): T | undefined {
return this.value.value;
}
set(value: T, tags: Tags = {}): Value<T | undefined> {
this._val = new ReadOnlyValue(this.name, value, {...this.tags, ...tags});
return this._val;
}
}
|