move to async/await
Signed-off-by: weboko <anon@mail.com>
This commit is contained in:
parent
88aa19b06f
commit
5bee034de8
|
@ -32,12 +32,11 @@ async function runApp() {
|
||||||
|
|
||||||
ui.onSendMessage(sendMessage);
|
ui.onSendMessage(sendMessage);
|
||||||
|
|
||||||
ui.onExit(() => {
|
ui.onExit(async () => {
|
||||||
ui.setStatus("disconnecting...");
|
ui.setStatus("disconnecting...");
|
||||||
unsubscribeFromMessages().then(() => {
|
await unsubscribeFromMessages();
|
||||||
ui.setStatus("disconnected");
|
ui.setStatus("disconnected");
|
||||||
ui.resetMessages();
|
ui.resetMessages();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,13 +123,12 @@ function initUI() {
|
||||||
exitButton.addEventListener("click", cb);
|
exitButton.addEventListener("click", cb);
|
||||||
},
|
},
|
||||||
onSendMessage: (cb) => {
|
onSendMessage: (cb) => {
|
||||||
sendButton.addEventListener("click", () => {
|
sendButton.addEventListener("click", async () => {
|
||||||
cb({
|
await cb({
|
||||||
nick: nickText.value,
|
nick: nickText.value,
|
||||||
text: messageText.value,
|
text: messageText.value,
|
||||||
}).then(() => {
|
|
||||||
messageText.value = "";
|
|
||||||
});
|
});
|
||||||
|
messageText.value = "";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// UI renderers
|
// UI renderers
|
||||||
|
|
Loading…
Reference in New Issue