Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions OpenScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,12 @@ var OpenScript = {
*/
listening = {};

/**
* All the states that this component is listening to
* @type {object<OpenScript.State>}
*/
states = {};

/**
* List of components that this component is listening
* to.
Expand Down Expand Up @@ -775,12 +781,6 @@ var OpenScript = {
*/
visible = true;

/**
* Keeps track of why the
* component is made visible or hidden
*/
visibleBy = 'parent';

/**
* Anonymous component ID
*/
Expand Down Expand Up @@ -1044,6 +1044,11 @@ var OpenScript = {
}
}

for(let id in this.states){
this.states[id]?.off(this);
delete this.states[id];
}

return true;
}

Expand Down Expand Up @@ -1293,6 +1298,7 @@ var OpenScript = {

if(args[i] instanceof OpenScript.State) {
args[i].listener(this);
this.states[args[i].id] = args[i];
final.states.push(args[i]);
}
}
Expand Down Expand Up @@ -1744,7 +1750,7 @@ var OpenScript = {
* @param {...any} args
* @returns
*/
fire(...args) {
async fire(...args) {

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

if(prop === "value") {
let current = target.value;
let nVal = value;

if(typeof current === "object"){
current = JSON.stringify(current);
nVal = JSON.stringify(nVal);
}

if(target.value === value) return true;
if(current === nVal) return true;

Reflect.set(...arguments);

Expand Down Expand Up @@ -2295,7 +2308,7 @@ var OpenScript = {
* @returns
*/
func = (component, method, ...args) => {
return `h.compMap.get('${component.name}')['${method}'](${this._escape(args)})`;
return `component('${component.name}')['${method}'](${this._escape(args)})`;
}

/**
Expand Down