Instead of using onDestroy, return a function from onMount
This commit is contained in:
parent
018ae4fe06
commit
b0e2a9e6d4
3 changed files with 21 additions and 13 deletions
|
|
@ -2,10 +2,11 @@
|
|||
import { Status, colours, spaceships } from "common";
|
||||
import SpaceShuttle from "../icons/spaceship.svelte";
|
||||
import SciFiButton from "../SciFi-Button.svelte";
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { createEventDispatcher, onMount } from "svelte";
|
||||
import { myName, players } from "../../stores";
|
||||
import BaseModal from "./BaseModal.svelte";
|
||||
import Hexagon from "../Hexagon.svelte";
|
||||
import { socket } from "../../main";
|
||||
|
||||
const emit = createEventDispatcher();
|
||||
|
||||
|
|
@ -20,6 +21,15 @@ 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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue