zhao/imports/ui/App.vue

66 lines
1.2 KiB
Vue
Raw Normal View History

2020-11-27 05:33:53 +00:00
<template>
<div>
2020-11-27 07:16:15 +00:00
<component
v-bind:is="whatScreen"
2020-11-27 07:34:12 +00:00
v-bind:currentRoom="currentRoom"
v-bind:players="players"
2020-11-27 07:16:15 +00:00
v-on:newGame="newGame"
v-on:joinGame="joinGame"
></component>
2020-11-27 05:33:53 +00:00
</div>
</template>
<script>
2020-11-27 07:34:12 +00:00
import Lobby from "./components/Lobby.vue"
import WaitingRoom from "./components/WaitingRoom.vue"
import Players from "../api/collections/Players";
2020-11-27 05:33:53 +00:00
export default {
components: {
Lobby,
2020-11-27 07:16:15 +00:00
WaitingRoom,
2020-11-27 05:33:53 +00:00
},
2020-11-27 07:34:12 +00:00
meteor: {
$subscribe: {
players: [],
},
players() {
return Players.find({});
},
},
2020-11-27 05:33:53 +00:00
data() {
return {
currentRoom: null,
whatScreen: Lobby,
};
},
2020-11-27 07:16:15 +00:00
methods: {
newGame: function(args) {
this.currentRoom = args;
this.whatScreen = WaitingRoom;
2020-11-27 07:34:12 +00:00
Meteor.subscribe("players", args.roomId, () => {
console.log("UPDATE", arguments);
});
2020-11-27 07:16:15 +00:00
},
joinGame: function(args) {
this.currentRoom = args;
this.whatScreen = WaitingRoom;
2020-11-27 07:34:12 +00:00
Meteor.subscribe("players", args.roomId, () => {
console.log("UPDATE", arguments);
});
2020-11-27 07:16:15 +00:00
},
}
2020-11-27 05:33:53 +00:00
}
</script>
<style>
2020-11-27 06:36:02 +00:00
body {
font-family: sans-serif;
padding: 10px;
}
2020-11-27 05:33:53 +00:00
</style>