Skip to content

Commit 1c15322

Browse files
committed
Post message when JS code changes.
1 parent 594dc59 commit 1c15322

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/components/ContentWrap.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ export default class ContentWrap extends Component {
8585
this.cmCodes.js,
8686
change.origin !== 'setValue'
8787
);
88-
this.onCodeChange(editor, change);
88+
89+
let now = new Date();
90+
console.log('post to iframe:' + this.cmCodes.js, now.toLocaleTimeString() + `.${now.getMilliseconds()}`)
91+
92+
document.getElementById('demo-frame').contentWindow.postMessage(this.cmCodes.js, window.location.href);
93+
now = new Date();
94+
console.log('posted to iframe:' + this.cmCodes.js, now.toLocaleTimeString() + `.${now.getMilliseconds()}`)
95+
96+
// this.onCodeChange(editor, change);
8997
}
9098
onCodeChange(editor, change) {
9199
clearTimeout(this.updateTimer);

src/computes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,15 @@ export function computeJs(
187187
shouldPreventInfiniteLoops,
188188
infiniteLoopTimeout
189189
) {
190+
console.log('Is it recomputing?')
190191
let code = `window.addEventListener('message', (e) => {
192+
const now = new Date();
193+
console.log('Received:' + e.data, now.toLocaleTimeString() + '.' + now.getMilliseconds())
194+
191195
app.$store.commit('code', e.data);
196+
// app.$store.state.code = e.data
192197
}, false);`;
198+
193199
var d = deferred();
194200
var errors;
195201

0 commit comments

Comments
 (0)