26665da7306dbf11249dc8d4612fa53a4406ba80
[demos/kafka/chat] / src / app / chatrooms / chatrooms.component.ts
1 import { Component, OnInit } from '@angular/core';
2 import { Chatroom } from '../chatroom';
3 import { UserService } from "../user.service";
4 import { ChatroomService } from "../chatroom.service";
5
6 @Component({
7   selector: 'app-chatrooms',
8   templateUrl: './chatrooms.component.html',
9   styleUrls: ['./chatrooms.component.less']
10 })
11 export class ChatroomsComponent implements OnInit
12 {
13   chatrooms: Chatroom[] = [];
14
15   constructor(
16     private chatroomsService: ChatroomService,
17     private userService: UserService) {}
18
19   ngOnInit(): void
20   {
21     this.userService.assertUserisKnown(() => this.getChatrooms());
22   }
23
24   getChatrooms(): void {
25     this.chatroomsService
26       .getChatrooms()
27       .subscribe(chatrooms => this.chatrooms = chatrooms);
28   }
29 }