Skip to content

Commit

Permalink
Refactor _uibCommand to simplify and make more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
TotallyInformation committed Mar 23, 2023
1 parent faa1fc1 commit e8d11e2
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 64 deletions.
34 changes: 16 additions & 18 deletions front-end/uibuilder.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4950,53 +4950,51 @@ var Uib = (_a = class {
}
const prop = msg._uib.prop;
const value2 = msg._uib.value;
switch (msg._uib.command) {
let response;
switch (cmd) {
case "get": {
msg.payload = msg._uib.response = this.get(prop);
if (!msg.topic)
msg.topic = this.topic || `uib get for '${prop}'`;
this.send(msg);
response = this.get(prop);
break;
}
case "htmlSend": {
this.htmlSend();
response = this.htmlSend();
break;
}
case "set": {
msg._uib.response = this.set(prop, value2);
if (!msg.topic)
msg.topic = this.topic || `uib set for '${prop}'`;
this.send(msg);
response = this.set(prop, value2);
break;
}
case "showMsg": {
this.showMsg(value2, prop);
response = this.showMsg(value2, prop);
break;
}
case "showStatus": {
this.showStatus(value2, prop);
response = this.showStatus(value2, prop);
break;
}
case "uiGet": {
this.send({
payload: this.uiGet(prop),
topic: this.topic || `uiGet for '${prop}'`
});
response = this.uiGet(prop);
break;
}
case "uiWatch": {
this.uiWatch(prop);
response = this.uiWatch(prop);
break;
}
case "include": {
this.include(prop, value2);
response = this.include(prop, value2);
break;
}
default: {
log("warning", "Uib:_uibCommand", `Command '${cmd}' not yet implemented`)();
break;
}
}
if (response !== void 0 && Object(response).constructor !== Promise) {
msg.payload = msg._uib.response = response;
if (!msg.topic)
msg.topic = this.topic || `uib ${cmd} for '${prop}'`;
this.send(msg);
}
}
// --- end of _uibCommand ---
// Handle received messages - Process some msgs internally, emit specific events on document that make it easy for coders to use
Expand Down
8 changes: 4 additions & 4 deletions front-end/uibuilder.esm.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions front-end/uibuilder.esm.min.js.map

Large diffs are not rendered by default.

34 changes: 16 additions & 18 deletions front-end/uibuilder.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -4951,53 +4951,51 @@
}
const prop = msg._uib.prop;
const value2 = msg._uib.value;
switch (msg._uib.command) {
let response;
switch (cmd) {
case "get": {
msg.payload = msg._uib.response = this.get(prop);
if (!msg.topic)
msg.topic = this.topic || `uib get for '${prop}'`;
this.send(msg);
response = this.get(prop);
break;
}
case "htmlSend": {
this.htmlSend();
response = this.htmlSend();
break;
}
case "set": {
msg._uib.response = this.set(prop, value2);
if (!msg.topic)
msg.topic = this.topic || `uib set for '${prop}'`;
this.send(msg);
response = this.set(prop, value2);
break;
}
case "showMsg": {
this.showMsg(value2, prop);
response = this.showMsg(value2, prop);
break;
}
case "showStatus": {
this.showStatus(value2, prop);
response = this.showStatus(value2, prop);
break;
}
case "uiGet": {
this.send({
payload: this.uiGet(prop),
topic: this.topic || `uiGet for '${prop}'`
});
response = this.uiGet(prop);
break;
}
case "uiWatch": {
this.uiWatch(prop);
response = this.uiWatch(prop);
break;
}
case "include": {
this.include(prop, value2);
response = this.include(prop, value2);
break;
}
default: {
log("warning", "Uib:_uibCommand", `Command '${cmd}' not yet implemented`)();
break;
}
}
if (response !== void 0 && Object(response).constructor !== Promise) {
msg.payload = msg._uib.response = response;
if (!msg.topic)
msg.topic = this.topic || `uib ${cmd} for '${prop}'`;
this.send(msg);
}
}
// --- end of _uibCommand ---
// Handle received messages - Process some msgs internally, emit specific events on document that make it easy for coders to use
Expand Down
8 changes: 4 additions & 4 deletions front-end/uibuilder.iife.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions front-end/uibuilder.iife.min.js.map

Large diffs are not rendered by default.

33 changes: 17 additions & 16 deletions src/front-end-module/uibuilder.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -2266,52 +2266,46 @@ export const Uib = class Uib {
}
const prop = msg._uib.prop
const value = msg._uib.value
let response

switch (msg._uib.command) {
switch (cmd) {
case 'get': {
msg.payload = msg._uib.response = this.get(prop)
if (!msg.topic) msg.topic = this.topic || `uib get for '${prop}'`
this.send(msg)
response = this.get(prop)
break
}

case 'htmlSend': {
this.htmlSend()
response = this.htmlSend()
break
}

case 'set': {
msg._uib.response = this.set(prop, value)
if (!msg.topic) msg.topic = this.topic || `uib set for '${prop}'`
this.send(msg)
response = this.set(prop, value)
break
}

case 'showMsg': {
this.showMsg(value, prop)
response = this.showMsg(value, prop)
break
}

case 'showStatus': {
this.showStatus(value, prop)
response = this.showStatus(value, prop)
break
}

case 'uiGet': {
this.send({
payload: this.uiGet(prop),
topic: this.topic || `uiGet for '${prop}'`,
})
response = this.uiGet(prop)
break
}

case 'uiWatch': {
this.uiWatch(prop)
response = this.uiWatch(prop)
break
}

case 'include': {
this.include(prop, value)
response = this.include(prop, value)
break
}

Expand All @@ -2320,6 +2314,13 @@ export const Uib = class Uib {
break
}
}

if (response !== undefined && Object(response).constructor !== Promise) {
msg.payload = msg._uib.response = response
if (!msg.topic) msg.topic = this.topic || `uib ${cmd} for '${prop}'`
this.send(msg)
}

} // --- end of _uibCommand ---

// Handle received messages - Process some msgs internally, emit specific events on document that make it easy for coders to use
Expand Down

0 comments on commit e8d11e2

Please sign in to comment.