// eslint-disable-next-line @definitelytyped/no-self-import import { ObserverMethod, UnwrapComputedPropertyGetter, UnwrapComputedPropertyGetters, UnwrapComputedPropertySetters, } from "@ember/object/-private/types"; // eslint-disable-next-line @definitelytyped/no-self-import import Mixin from "@ember/object/mixin"; // eslint-disable-next-line @definitelytyped/no-self-import import CoreObject from "@ember/object/core"; /** * This mixin provides properties and property observing functionality, core features of the Ember object model. */ interface Observable { /** * Retrieves the value of a property from the object. */ get(key: K): UnwrapComputedPropertyGetter; /** * To get the values of multiple properties at once, call `getProperties` * with a list of strings or an array: */ getProperties( list: K[], ): Pick, K>; getProperties( ...list: K[] ): Pick, K>; /** * Sets the provided key or path to the value. */ set(key: K, value: this[K]): this[K]; set(key: keyof this, value: T): T; /** * Sets a list of properties at once. These properties are set inside * a single `beginPropertyChanges` and `endPropertyChanges` batch, so * observers will be buffered. */ setProperties( hash: Pick, ): Pick, K>; setProperties( // tslint:disable-next-line:unified-signatures hash: { [KK in K]: any }, ): Pick, K>; /** * Notify the observer system that a property has just changed. * * Sometimes you need to change a value directly or indirectly without * actually calling `get()` or `set()` on it. In this case, you can use this * method instead. Calling this method will notify all observers that the * property has potentially changed value. */ notifyPropertyChange(keyName: string): this; /** * Adds an observer on a property. */ addObserver( key: keyof this, target: Target, method: ObserverMethod, ): this; addObserver(key: keyof this, method: ObserverMethod): this; /** * Remove an observer you have previously registered on this object. Pass * the same key, target, and method you passed to `addObserver()` and your * target will no longer receive notifications. */ removeObserver( key: keyof this, target: Target, method: ObserverMethod, ): this; removeObserver(key: keyof this, method: ObserverMethod): this; /** * Set the value of a property to the current value plus some amount. */ incrementProperty(keyName: keyof this, increment?: number): number; /** * Set the value of a property to the current value minus some amount. */ decrementProperty(keyName: keyof this, decrement?: number): number; /** * Set the value of a boolean property to the opposite of its * current value. */ toggleProperty(keyName: keyof this): boolean; /** * Returns the cached value of a computed property, if it exists. * This allows you to inspect the value of a computed property * without accidentally invoking it if it is intended to be * generated lazily. */ cacheFor( key: K, ): UnwrapComputedPropertyGetter | undefined; } declare const Observable: Mixin; export default Observable;