chore: cleanup

This commit is contained in:
Nathan Walker
2023-03-21 19:44:08 -07:00
parent 344be0c38e
commit 18c443c8b5

View File

@@ -108,10 +108,16 @@ export class Observable {
private readonly _observers: { [eventName: string]: ListenerEntry[] } = {};
/**
* Gets the value of the specified property.
*/
public get(name: string): any {
return this[name];
}
/**
* Updates the specified property with the provided value.
*/
public set(name: string, value: any): void {
// TODO: Parameter validation
const oldValue = this[name];
@@ -124,6 +130,9 @@ export class Observable {
this.notifyPropertyChange(name, newValue, oldValue);
}
/**
* Updates the specified property with the provided value and raises a property change event and a specific change event based on the property name.
*/
public setProperty(name: string, value: any): void {
const oldValue = this[name];
if (this[name] === value) {
@@ -474,28 +483,6 @@ export class Observable {
}
}
export interface Observable {
/**
* Raised when a propertyChange occurs.
*/
on(event: 'propertyChange', callback: (data: EventData) => void, thisArg?: any): void;
/**
* Updates the specified property with the provided value.
*/
set(name: string, value: any): void;
/**
* Updates the specified property with the provided value and raises a property change event and a specific change event based on the property name.
*/
setProperty(name: string, value: any): void;
/**
* Gets the value of the specified property.
*/
get(name: string): any;
}
class ObservableFromObject extends Observable {
public readonly _map: Record<string, any> = {};