Use extends and super for Object
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @module ol/Object
|
* @module ol/Object
|
||||||
*/
|
*/
|
||||||
import {getUid, inherits} from './util.js';
|
import {getUid} from './util.js';
|
||||||
import ObjectEventType from './ObjectEventType.js';
|
import ObjectEventType from './ObjectEventType.js';
|
||||||
import Observable from './Observable.js';
|
import Observable from './Observable.js';
|
||||||
import Event from './events/Event.js';
|
import Event from './events/Event.js';
|
||||||
@@ -11,9 +11,8 @@ import {assign} from './obj.js';
|
|||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
* Events emitted by {@link module:ol/Object~BaseObject} instances are instances of this type.
|
* Events emitted by {@link module:ol/Object~BaseObject} instances are instances of this type.
|
||||||
* @extends {module:ol/events/Event}
|
*/
|
||||||
*/
|
class ObjectEvent extends Event {
|
||||||
class ObjectEvent {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} type The event type.
|
* @param {string} type The event type.
|
||||||
@@ -21,7 +20,7 @@ class ObjectEvent {
|
|||||||
* @param {*} oldValue The old value for `key`.
|
* @param {*} oldValue The old value for `key`.
|
||||||
*/
|
*/
|
||||||
constructor(type, key, oldValue) {
|
constructor(type, key, oldValue) {
|
||||||
Event.call(this, type);
|
super(type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the property whose value is changing.
|
* The name of the property whose value is changing.
|
||||||
@@ -42,8 +41,6 @@ class ObjectEvent {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inherits(ObjectEvent, Event);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
@@ -85,17 +82,16 @@ inherits(ObjectEvent, Event);
|
|||||||
* Properties can be deleted by using the unset method. E.g.
|
* Properties can be deleted by using the unset method. E.g.
|
||||||
* object.unset('foo').
|
* object.unset('foo').
|
||||||
*
|
*
|
||||||
* @extends {module:ol/Observable}
|
|
||||||
* @fires module:ol/Object~ObjectEvent
|
* @fires module:ol/Object~ObjectEvent
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class BaseObject {
|
class BaseObject extends Observable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object.<string, *>=} opt_values An object with key-value pairs.
|
* @param {Object.<string, *>=} opt_values An object with key-value pairs.
|
||||||
*/
|
*/
|
||||||
constructor(opt_values) {
|
constructor(opt_values) {
|
||||||
Observable.call(this);
|
super();
|
||||||
|
|
||||||
// Call {@link module:ol~getUid} to ensure that the order of objects' ids is
|
// Call {@link module:ol~getUid} to ensure that the order of objects' ids is
|
||||||
// the same as the order in which they were created. This also helps to
|
// the same as the order in which they were created. This also helps to
|
||||||
@@ -207,8 +203,6 @@ class BaseObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inherits(BaseObject, Observable);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Object.<string, string>}
|
* @type {Object.<string, string>}
|
||||||
|
|||||||
Reference in New Issue
Block a user