Move the onMount function call

This commit is contained in:
Oliver Akins 2022-07-19 22:53:49 -06:00
parent 4ab85924a9
commit 6f7477eecf
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99

View file

@ -21,24 +21,9 @@ var selectedColour = player.colour.hex;
var selectedShip = player.ship.id;
var error = null;
function designUpdate(data: any) {};
onMount(() => {
socket.on(`req:lobby.players.update`, designUpdate);
return () => {
socket.off(`req:lobby.players.update`);
};
});
function saveShipDesign() {
/* TODO: Send event to server, wait for confirmation */
let response: any = {
status: Status.UnknownError,
message: `Testing the error design`,
};
if (response.status != Status.Success) {
error = response.message;
function designUpdate(data: any) {
if (data.status != Status.Success) {
error = data.message;
/*
TODO (Maybe): If the list of colours doesn't auto-update the available
@ -57,6 +42,23 @@ function saveShipDesign() {
emit(`close`);
};
onMount(() => {
socket.on(`req:lobby.players.update`, designUpdate);
return () => {
socket.off(`req:lobby.players.update`);
};
});
function saveShipDesign() {
/* TODO: Send event to server, wait for confirmation */
let response: any = {
status: Status.UnknownError,
message: `Testing the error design`,
};
socket.emit(`req:lobby.players.update`, {});
};
</script>