mlpcardgame/src/store/network/getters.ts

22 lines
478 B
TypeScript

import { GetterTree } from "vuex";
import { AppState } from "../types";
import { NetworkState } from "./types";
const getters: GetterTree<NetworkState, AppState> = {
peerID(state): string | null {
switch (state.peerType) {
case "server":
return state.server.id;
case "client":
return state.peer.id;
}
return null;
},
connectionType(state): "client" | "server" | "none" {
return state.peerType;
}
};
export default getters;