UNPKG

2.46 kBTypeScriptView Raw
1import { EventsKey } from './events';
2import BaseEvent from './events/Event';
3import Observable from './Observable';
4
5export default class BaseObject extends Observable {
6 constructor(opt_values?: { [key: string]: any });
7 /**
8 * Apply any properties from another object without triggering events.
9 */
10 protected applyProperties(source: BaseObject): void;
11 /**
12 * Gets a value.
13 */
14 get(key: string): any;
15 /**
16 * Get a list of object property names.
17 */
18 getKeys(): string[];
19 /**
20 * Get an object of all property names and values.
21 */
22 getProperties(): { [key: string]: any };
23 hasProperties(): boolean;
24 notify(key: string, oldValue: any): void;
25 /**
26 * Sets a value.
27 */
28 set(key: string, value: any, opt_silent?: boolean): void;
29 /**
30 * Sets a collection of key-value pairs. Note that this changes any existing
31 * properties and adds new ones (it does not remove any existing properties).
32 */
33 setProperties(values: { [key: string]: any }, opt_silent?: boolean): void;
34 /**
35 * Unsets a property.
36 */
37 unset(key: string, opt_silent?: boolean): void;
38 on(type: string | string[], listener: (p0: any) => any): EventsKey | EventsKey[];
39 once(type: string | string[], listener: (p0: any) => any): EventsKey | EventsKey[];
40 un(type: string | string[], listener: (p0: any) => any): void;
41 on(type: 'change', listener: (evt: BaseEvent) => void): EventsKey;
42 once(type: 'change', listener: (evt: BaseEvent) => void): EventsKey;
43 un(type: 'change', listener: (evt: BaseEvent) => void): void;
44 on(type: 'error', listener: (evt: BaseEvent) => void): EventsKey;
45 once(type: 'error', listener: (evt: BaseEvent) => void): EventsKey;
46 un(type: 'error', listener: (evt: BaseEvent) => void): void;
47 on(type: 'propertychange', listener: (evt: ObjectEvent) => void): EventsKey;
48 once(type: 'propertychange', listener: (evt: ObjectEvent) => void): EventsKey;
49 un(type: 'propertychange', listener: (evt: ObjectEvent) => void): void;
50}
51export class ObjectEvent extends BaseEvent {
52 constructor(type: string, key: string, oldValue: any);
53 /**
54 * The name of the property whose value is changing.
55 */
56 key: string;
57 /**
58 * The old value. To get the new value use e.target.get(e.key) where
59 * e is the event object.
60 */
61 oldValue: any;
62}
63export function getChangeEventType(key: string): string;