Skip to content

Commit 1fcf319

Browse files
authored
Merge pull request #16 from levizwannah/develop
Develop
2 parents 99feba7 + 92e59f4 commit 1fcf319

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

OpenScript.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,12 @@ var OpenScript = {
739739
*/
740740
listening = {};
741741

742+
/**
743+
* All the states that this component is listening to
744+
* @type {object<OpenScript.State>}
745+
*/
746+
states = {};
747+
742748
/**
743749
* List of components that this component is listening
744750
* to.
@@ -775,12 +781,6 @@ var OpenScript = {
775781
*/
776782
visible = true;
777783

778-
/**
779-
* Keeps track of why the
780-
* component is made visible or hidden
781-
*/
782-
visibleBy = 'parent';
783-
784784
/**
785785
* Anonymous component ID
786786
*/
@@ -1044,6 +1044,11 @@ var OpenScript = {
10441044
}
10451045
}
10461046

1047+
for(let id in this.states){
1048+
this.states[id]?.off(this);
1049+
delete this.states[id];
1050+
}
1051+
10471052
return true;
10481053
}
10491054

@@ -1293,6 +1298,7 @@ var OpenScript = {
12931298

12941299
if(args[i] instanceof OpenScript.State) {
12951300
args[i].listener(this);
1301+
this.states[args[i].id] = args[i];
12961302
final.states.push(args[i]);
12971303
}
12981304
}
@@ -1744,7 +1750,7 @@ var OpenScript = {
17441750
* @param {...any} args
17451751
* @returns
17461752
*/
1747-
fire(...args) {
1753+
async fire(...args) {
17481754

17491755
for(let [k, component] of this.listeners){
17501756
component.wrap(...args, this.signature);
@@ -1798,8 +1804,15 @@ var OpenScript = {
17981804
set(target, prop, value) {
17991805

18001806
if(prop === "value") {
1807+
let current = target.value;
1808+
let nVal = value;
1809+
1810+
if(typeof current === "object"){
1811+
current = JSON.stringify(current);
1812+
nVal = JSON.stringify(nVal);
1813+
}
18011814

1802-
if(target.value === value) return true;
1815+
if(current === nVal) return true;
18031816

18041817
Reflect.set(...arguments);
18051818

@@ -2295,7 +2308,7 @@ var OpenScript = {
22952308
* @returns
22962309
*/
22972310
func = (component, method, ...args) => {
2298-
return `h.compMap.get('${component.name}')['${method}'](${this._escape(args)})`;
2311+
return `component('${component.name}')['${method}'](${this._escape(args)})`;
22992312
}
23002313

23012314
/**

0 commit comments

Comments
 (0)