From 8acb67a1201a330506b4457985a3044cdccdc8b6 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 21 Sep 2014 05:35:05 -0700 Subject: [PATCH] nmbug.js: Use bind to avoid forwarding message_id through _get_tags Instead of telling _get_tags that the callback will always want the message_id (in addition to the list of that message's tags), use bind [1] to add that information when we set the _edit_tags callback. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind --- nmbug.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nmbug.js b/nmbug.js index 2bbde90..8b8dcba 100644 --- a/nmbug.js +++ b/nmbug.js @@ -2,7 +2,7 @@ var nmbug_server = 'http://localhost:5000'; nmbug = { show: function (message_id) { - this._get_tags(message_id, this._edit_tags.bind(this)); + this._get_tags(message_id, this._edit_tags.bind(this, message_id)); }, _get_tags: function (message_id, callback) { var url = [ @@ -16,7 +16,7 @@ nmbug = { if (this.status == 200) { var tags = JSON.parse(this.response); console.log('nmbug: got tags', tags); - callback(message_id, tags); + callback(tags); } else { throw 'Error fetching ' + url + ' (status ' + this.status + ')'; } -- 2.26.2