From 525f5dd460b12fe77509d2b3377248734f7ca1bf Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 18 Oct 2014 02:02:08 +0100 Subject: [PATCH] Re-implementing PluginInterface event.wait --- server/plugininterface.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/plugininterface.js b/server/plugininterface.js index d74ec6c..e9ec2f9 100644 --- a/server/plugininterface.js +++ b/server/plugininterface.js @@ -72,16 +72,23 @@ PluginInterface.prototype.emit = function emit(type, data) { var event_data = { callback: function () { resolve(data); + event_data.callback = null; }, preventDefault: function (reason) { rejected = true; if (reason) { rejected_reasons.push(reason); } - } + }, + wait: false }; listener(event_data, data); + + // If the module has not specified that we should wait, callback now + if (!event_data.wait && event_data.callback) { + event_data.callback(); + } }); }); }, Promise.resolve(data)); -- 2.25.1