Skip to content

Commit 1883433

Browse files
committed
Fixed on_update from WebWorker
1 parent 49a470c commit 1883433

File tree

1 file changed

+14
-4
lines changed
  • packages/perspective/src/js

1 file changed

+14
-4
lines changed

packages/perspective/src/js/api.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ import {bindall} from "./utils.js";
1111

1212
function unsubscribe(method, cmd) {
1313
return function() {
14-
let resolve = arguments[arguments.length - 1];
14+
let resolve;
1515
let reject = () => {};
16-
let args = Array.prototype.slice.call(arguments, 0, arguments.length - 1);
16+
let args = Array.prototype.slice.call(arguments, 0, arguments.length);
17+
for (let i = args.length - 1; i >= 0; i--) {
18+
if (typeof args[i] === "function") {
19+
resolve = args.splice(i, 1)[0];
20+
}
21+
}
1722
let msg = {
1823
cmd: cmd || "view_method",
1924
name: this._name,
@@ -28,9 +33,14 @@ function unsubscribe(method, cmd) {
2833

2934
function subscribe(method, cmd) {
3035
return function() {
31-
let resolve = arguments[arguments.length - 1];
36+
let resolve;
3237
let reject = () => {};
33-
let args = Array.prototype.slice.call(arguments, 0, arguments.length - 1);
38+
let args = Array.prototype.slice.call(arguments, 0, arguments.length);
39+
for (let i = args.length - 1; i >= 0; i--) {
40+
if (typeof args[i] === "function") {
41+
resolve = args.splice(i, 1)[0];
42+
}
43+
}
3444
let msg = {
3545
cmd: cmd || "view_method",
3646
name: this._name,

0 commit comments

Comments
 (0)