Skip to content

Commit

Permalink
refactor reviver
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Nov 12, 2023
1 parent 89ce9a9 commit 7b42399
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
19 changes: 6 additions & 13 deletions assets/js/watchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,13 @@ const watcherMixin = {

const reviveMixin = {
methods: {
revive_payload: function(obj) {
if (typeof obj === 'object') {
for (var key in obj) {
if ( (typeof obj[key] === 'object') && (obj[key]!=null) && !(obj[key].jsfunction) ) {
this.revive_payload(obj[key])
} else {
if ( (obj[key]!=null) && (obj[key].jsfunction) ) {
obj[key] = Function(obj[key].jsfunction.arguments, obj[key].jsfunction.body)
}
}
}
revive_jsfunction: function (k, v) {
if ( (typeof v==='object') && (v!=null) && (v.jsfunction) ) {
return Function(v.jsfunction.arguments, v.jsfunction.body)
} else {
return v
}
return obj;
}
}
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/Elements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,13 @@ function vue_integration(::Type{M};
window.parse_payload = function(payload){
if (payload.key) {
window.$(vue_app_name).revive_payload(payload)
window.$(vue_app_name).updateField(payload.key, payload.value);
window.$(vue_app_name).updateField(payload.key, payload.value);
}
}
function app_ready() {
$vue_app_name.isready = true;
Genie.addReviver(window.$(vue_app_name).revive_jsfunction);
$(transport == Genie.WebChannels &&
"
try {
Expand Down

0 comments on commit 7b42399

Please sign in to comment.