зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1299411 - s/on/once/ in NativeApp's sendMessage r=aswan
This communicates more clearly that we expect only one message/event. MozReview-Commit-ID: 8jDYBVwqQtz --HG-- extra : rebase_source : acae1570537b17027901253afc2344ffabd7a9ee
This commit is contained in:
Родитель
edfaa70caa
Коммит
13c2b6a47f
|
@ -430,8 +430,8 @@ this.NativeApp = class extends EventEmitter {
|
||||||
|
|
||||||
sendMessage(msg) {
|
sendMessage(msg) {
|
||||||
let responsePromise = new Promise((resolve, reject) => {
|
let responsePromise = new Promise((resolve, reject) => {
|
||||||
this.on("message", (what, msg) => { resolve(msg); });
|
this.once("message", (what, msg) => { resolve(msg); });
|
||||||
this.on("disconnect", (what, err) => { reject(err); });
|
this.once("disconnect", (what, err) => { reject(err); });
|
||||||
});
|
});
|
||||||
|
|
||||||
let result = this.startupPromise.then(() => {
|
let result = this.startupPromise.then(() => {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче