Many updates and improvements. For styles you can now combine two properties with a converter to get more custom styling updates. Cleaned up code and made a few things easier to use, also fixed a few bugs.
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
* @ignore
|
||||
*/
|
||||
class IgniteProperty {
|
||||
constructor(val) {
|
||||
constructor(val, onChange = null) {
|
||||
this.onChangeCallbacks = [];
|
||||
this.onPushCallbacks = [];
|
||||
this.onPopCallbacks = [];
|
||||
@ -13,6 +13,11 @@ class IgniteProperty {
|
||||
this._value = val;
|
||||
this.ignoreValueChange = false;
|
||||
|
||||
//If we were passed an onchange function attach it.
|
||||
if (onChange) {
|
||||
this.attachOnChange(onChange);
|
||||
}
|
||||
|
||||
//Attempt to patch the value if it's a list.
|
||||
this.patchArray();
|
||||
}
|
||||
@ -40,6 +45,7 @@ class IgniteProperty {
|
||||
//Invoke any callbacks letting them know the value changed.
|
||||
this.invokeOnChange(old, val);
|
||||
|
||||
//If we want to reflect the value then bubble it up.
|
||||
if (reflect) {
|
||||
this.ignoreValueChange = true; //Ignore changes incase we are connected to any reflected properties.
|
||||
this.reflected.forEach(reflect => reflect.value = val);
|
||||
@ -157,6 +163,30 @@ IgniteProperty.prototype.toString = function () {
|
||||
return this.value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a prototype to help get property values from an array
|
||||
*/
|
||||
Array.prototype.getPropertyValues = function () {
|
||||
var ret = [];
|
||||
this.forEach(prop => ret.push(prop.value));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a prototype to help get old property values from an array
|
||||
*/
|
||||
Array.prototype.getOldPropertyValues = function (property, oldValue) {
|
||||
var ret = [];
|
||||
this.forEach(prop => {
|
||||
if (prop == property) {
|
||||
ret.push(oldValue);
|
||||
} else {
|
||||
ret.push(prop.value);
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* The outline of a ignite callback that can be invoked and disconnected
|
||||
* to help maintain and cleanup callbacks.
|
||||
@ -205,6 +235,20 @@ class IgniteRenderingContext {
|
||||
}
|
||||
}
|
||||
|
||||
static push() {
|
||||
if (IgniteRenderingContext.Stack == null) {
|
||||
IgniteRenderingContext.Stack = [];
|
||||
}
|
||||
|
||||
IgniteRenderingContext.Stack.push(IgniteRenderingContext.RenderCount);
|
||||
IgniteRenderingContext.RenderCount = 0;
|
||||
}
|
||||
|
||||
static pop() {
|
||||
if (IgniteRenderingContext.Stack && IgniteRenderingContext.Stack.length > 0) {
|
||||
IgniteRenderingContext.RenderCount = IgniteRenderingContext.Stack.pop();
|
||||
}
|
||||
}
|
||||
static ready(callback) {
|
||||
//Setup the callbacks if it's not init'd.
|
||||
if (!IgniteRenderingContext.ReadyCallbacks) {
|
||||
|
Reference in New Issue
Block a user