export type ClassOptions = Record; /** * * 基类(Class) * 该库中所有的类都继承于该基类。 * 该类提供了定义新类时常用的工具方法,如管理配置options,添加 init hooks 等。 * * @english * This library uses ES2015 class system. * Class is the root class of class hierachy. * It provides utility methods to make it easier to manage configration options, merge mixins and add init hooks. * * @example * const defaultOptions = { * 'foo' : 'bar' * }; * class Foo extends maptalks.Class { * constructor(id, options) { * super(options); * this.setId(id); * } * * setId(id) { * this.id = id; * } * * whenCreated() { * // ..... * } * } * * Foo.mergeOptions(defaultOptions); * * Foo.addInitHook('whenCreated'); * @category core */ declare class Class { options?: ClassOptions; /** * * @english * Create an object, set options if given and call all the init hooks.
* Options is where the object manages its configuration. Options passed to the object will be merged with parent's instead of overriding it. * * @param options - options to set */ constructor(options?: ClassOptions); proxyOptions(): this; /** * 遍历并执行该类或父类用 addInitHook 添加的 init hooks * * @english * Visit and call all the init hooks defined on Class and its parents. */ callInitHooks(): this; /** * 设置新的配置 options * * @english * Merges options with the default options of the object. * @param options - options to set */ _setOptions(options: ClassOptions): this; setOptions(options: ClassOptions): this; /** * * 更新options中指定的配置项。 * 1. 如果没有提供参数,则返回options配置对象 * 2. 如果配置项有对应的handler,handler会被启用或停用,例如draggable * * @english * 1. Return object's options if no parameter is provided.
* 2. update an option and enable/disable the handler if a handler with the same name existed. * * @example * // Get marker's options; * const options = marker.config(); * // Set map's option "draggable" to false and disable map's draggable handler. * map.config('draggable', false); * // You can update more than one options like this: * map.config({ * 'scrollWheelZoom' : false, * 'doubleClickZoom' : false * }); * @param conf - config to update * @return */ config(conf?: string | ClassOptions, value?: any): ClassOptions | this; /** * options被更新时的回调函数 * * @english * Default callback when config is called * * @param conf - updated options */ onConfig(conf: ClassOptions): void; /** * 添加一个初始化钩子(init hook)方法,实例化时会被调用。 * 该方法一般用于插件开发,利用初始化钩子,子类无需重载父类的构造函数(constructor),就可以在实例化时执行一些必要的逻辑 * * @english * Add an init hook, which will be called when the object is initiated.
* It is useful in plugin developing to do things when creating objects without changing class's constructor. * @param fn - a hook function or name of the hook function * @param args - arguments for the init hook function */ static addInitHook(fn: Function | string, ...args: any[]): typeof Class; /** * 将一个或多个,sources中定义的方法或属性,mixin到该类的prototype中 * * @english * Mixin the specified objects into the class as prototype properties or methods. * @param sources - objects to mixin */ static include(...sources: any[]): typeof Class; /** * 用参数中的options定义扩展默认的options * * @english * Mixin options with the class's default options. * @param options - options to merge. */ static mergeOptions(options: ClassOptions): typeof Class; } export default Class; //# sourceMappingURL=Class.d.ts.map