Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace atomic #603

Merged
merged 5 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixed bad server message route
  • Loading branch information
texodus committed May 30, 2019
commit 864174d8cbf7de92185f45ce79bff93f553751ef
18 changes: 11 additions & 7 deletions packages/perspective/src/js/API/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Server {
this._tables = {};
this._views = {};

this._callback_cache = new WeakMap();
this._callback_cache = new Map();
}

/**
Expand Down Expand Up @@ -134,7 +134,7 @@ export class Server {
process_subscribe(msg, obj) {
try {
let callback;
if (msg.cmd.slice(0, 2) === "on") {
if (msg.method.slice(0, 2) === "on") {
callback = ev => {
let result = {
id: msg.id,
Expand All @@ -152,17 +152,21 @@ export class Server {
this.post(result);
} catch (e) {
console.error("Removing callback after failed on_update() (presumably due to closed connection)");
//if (msg.method === "on_update") {
obj["remove_update"](callback);
//}
}
};
this._callback_cache.set(msg.callback_id, callback);
} else {
if (msg.callback_id) {
this._callback_cache.set(msg.callback_id, callback);
}
} else if (msg.callback_id) {
callback = this._callback_cache.get(msg.callback_id);
this._callback_cache.delete(msg.callback_id);
}
obj[msg.method](callback, ...msg.args); // make sure we are passing arguments into the callback
if (callback) {
obj[msg.method](callback, ...msg.args);
} else {
console.error(`Callback not found for remote call "${msg}"`);
}
} catch (error) {
this.process_error(msg, error);
return;
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function jest() {
}

if (args.indexOf("--debug") > -1) {
console.log("Running tests in debug mode - all console.log statements are preserved.");
console.log("-- Running tests in debug mode - all console.log statements are preserved.");
} else {
cmd += " --silent 2>&1";
}
Expand Down