Skip to content

Commit

Permalink
Make events async
Browse files Browse the repository at this point in the history
  • Loading branch information
raub committed Nov 7, 2023
1 parent 5cdb8c6 commit 9265bd7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions js/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ class JsView extends View {
viewInstances[this._index] = this;

this._silent = !! opts.silent;
this.on('_qml_error', (data) => {
this.on('_qml_error', (data) => setImmediate(() => {
if (!this._silent) {
console.error(`Qml Error: (${data.type})`, data.message);
}
this.emit('error', new Error(`${data.type}: ${data.message}`));
});
}));

// Expect FBO texture
this.on('_qml_fbo', (data) => {
this.on('_qml_fbo', (data) => setImmediate(() => {
this._textureId = data.texture;
this.emit('reset', this._textureId);
});
}));


this.on('_qml_load', (e) => {
this.on('_qml_load', (e) => setImmediate(() => {
if (e.source !== this._finalSource) {
return;
}
Expand All @@ -82,10 +82,10 @@ class JsView extends View {
this._isLoaded = true;

this.emit('load');
});
}));

this.on('_qml_mouse', (e) => this.emit(e.type, e));
this.on('_qml_key', (e) => this.emit(e.type, e));
this.on('_qml_mouse', (e) => setImmediate(() => this.emit(e.type, e)));
this.on('_qml_key', (e) => setImmediate(() => this.emit(e.type, e)));

if (opts.file || opts.source) {
this.load(opts);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Luis Blanco <luisblanco1337@gmail.com>",
"name": "qml-raub",
"version": "3.0.0",
"version": "3.0.1",
"description": "QML interoperation for Node.js",
"license": "MIT",
"main": "index.js",
Expand Down

0 comments on commit 9265bd7

Please sign in to comment.