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:
2021-03-28 20:34:35 -07:00
parent 92a5eb3384
commit f49aad478c
2 changed files with 83 additions and 8 deletions

View File

@ -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();
}