Move the onMount function call
This commit is contained in:
parent
4ab85924a9
commit
6f7477eecf
1 changed files with 20 additions and 18 deletions
|
|
@ -21,24 +21,9 @@ var selectedColour = player.colour.hex;
|
||||||
var selectedShip = player.ship.id;
|
var selectedShip = player.ship.id;
|
||||||
var error = null;
|
var error = null;
|
||||||
|
|
||||||
function designUpdate(data: any) {};
|
function designUpdate(data: any) {
|
||||||
|
if (data.status != Status.Success) {
|
||||||
onMount(() => {
|
error = data.message;
|
||||||
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;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO (Maybe): If the list of colours doesn't auto-update the available
|
TODO (Maybe): If the list of colours doesn't auto-update the available
|
||||||
|
|
@ -57,6 +42,23 @@ function saveShipDesign() {
|
||||||
|
|
||||||
emit(`close`);
|
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>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue