Added Variables to ignite element. Added ability to create an IgniteProperty with a set of optional callbacks to create advanced components.
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
* @ignore
|
||||
*/
|
||||
class IgniteProperty {
|
||||
constructor(val, onChange = null) {
|
||||
constructor(val, options = null) {
|
||||
this.onChangeCallbacks = [];
|
||||
this.onPushCallbacks = [];
|
||||
this.onPopCallbacks = [];
|
||||
@ -17,11 +17,33 @@ class IgniteProperty {
|
||||
this._value = val;
|
||||
this.ignoreValueChange = false;
|
||||
|
||||
//If we were passed an onchange function attach it.
|
||||
if (onChange) {
|
||||
this.attachOnChange(onChange);
|
||||
}
|
||||
//If we were passed options, add any callbacks needed.
|
||||
if (options) {
|
||||
if (options.onChange) {
|
||||
this.attachOnChange(options.onChange);
|
||||
}
|
||||
|
||||
if (options.onPush) {
|
||||
this.attachOnPush(options.onPush);
|
||||
}
|
||||
|
||||
if (options.onPop) {
|
||||
this.attachOnPop(options.onPop);
|
||||
}
|
||||
|
||||
if (options.onShift) {
|
||||
this.attachOnShift(options.onShift);
|
||||
}
|
||||
|
||||
if (options.onUnshift) {
|
||||
this.attachOnUnshift(options.onUnshift);
|
||||
}
|
||||
|
||||
if (options.onSplice) {
|
||||
this.attachOnSplice(options.onSplice);
|
||||
}
|
||||
}
|
||||
|
||||
//Attempt to patch the value if it's a list.
|
||||
this.patchArray();
|
||||
}
|
||||
|
Reference in New Issue
Block a user