Added support for property change with same object instance (via WrappedValue).

This commit is contained in:
Nedyalko Nikolov
2016-01-22 08:27:31 +02:00
parent 8159929ff7
commit 5c35f33441
4 changed files with 139 additions and 18 deletions

View File

@@ -29,6 +29,37 @@ declare module "data/observable" {
*/
value: any;
}
/**
* Helper class that is used to fire property change even when real object is the same.
* By default property change will not be fired for a same object.
* By wrapping object into a WrappedValue instance `same object restriction` will be passed.
*/
class WrappedValue {
/**
* Property which holds the real value.
*/
wrapped: any;
/**
* Creates an instance of WrappedValue object.
* @param value - the real value which should be wrapped.
*/
constructor(value: any);
/**
* Gets the real value of previously wrappedValue.
* @param value - Value that should be unwraped. If there is no wrappedValue property of the value object then value will be returned.
*/
static unwrap(value: any): any;
/**
* Returns an instance of WrappedValue. The actual instance is get from a WrappedValues pool.
* @param value - Value that should be wrapped.
*/
static wrap(value: any): WrappedValue
}
/**
* Observable is used when you want to be notified when a change occurs. Use on/off methods to add/remove listener.