Selector/Selector.Web/scripts/now.ts

49 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-10-31 19:47:07 +00:00
import * as signalR from "@microsoft/signalr";
2021-11-09 18:17:22 +00:00
import * as Vue from "vue";
2021-11-05 07:58:48 +00:00
import { FullTrack, CurrentlyPlayingDTO } from "./HubInterfaces";
import NowPlayingCard from "./NowPlayingCard";
2021-10-31 19:47:07 +00:00
const connection = new signalR.HubConnectionBuilder()
.withUrl("/hub")
.build();
connection.start().catch(err => console.error(err));
interface NowPlaying {
currentlyPlaying?: CurrentlyPlayingDTO
}
2021-11-09 18:17:22 +00:00
const app = Vue.createApp({
data() {
return {
currentlyPlaying: {
track: {
name: "No Playback",
album: {
name: "",
images: [
{
url: ""
}
]
},
artists: [
{
name: ""
}
]
}
}
} as NowPlaying
2021-11-09 18:17:22 +00:00
},
created() {
connection.on("OnNewPlaying", (context: CurrentlyPlayingDTO) =>
{
console.log(context);
this.currentlyPlaying = context;
});
2021-11-09 18:17:22 +00:00
}
});
app.component("now-playing-card", NowPlayingCard);
2021-11-09 18:17:22 +00:00
const vm = app.mount('#app');