diff options
author | Nick Van Doorn <vandoorn.nick@gmail.com> | 2019-03-04 01:57:27 -0800 |
---|---|---|
committer | Nick Van Doorn <vandoorn.nick@gmail.com> | 2019-03-04 01:57:27 -0800 |
commit | c973da44da1ede938a6b4dfb712226992cc76bbe (patch) | |
tree | bddf61b9055d2133c352f3611b205b41cdc203f8 /sample-apps | |
parent | e2cf4851bdbdc5ad551728f9e6a3f742f4fb848b (diff) |
Add chat room directory to app component
Diffstat (limited to 'sample-apps')
-rw-r--r-- | sample-apps/angular-chat/src/app/app.component.html | 6 | ||||
-rw-r--r-- | sample-apps/angular-chat/src/app/app.component.ts | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/sample-apps/angular-chat/src/app/app.component.html b/sample-apps/angular-chat/src/app/app.component.html index 1e28015..ec6739b 100644 --- a/sample-apps/angular-chat/src/app/app.component.html +++ b/sample-apps/angular-chat/src/app/app.component.html @@ -1,4 +1,10 @@ <div> + Chat Room directory: + <ul> + <li *ngFor="let room of (directory$ | async)"> + {{room}} + </li> + </ul> <form> <label>Username</label> <input type="text" name="user-id" [(ngModel)]="userId" /> diff --git a/sample-apps/angular-chat/src/app/app.component.ts b/sample-apps/angular-chat/src/app/app.component.ts index 8048476..02a1f9e 100644 --- a/sample-apps/angular-chat/src/app/app.component.ts +++ b/sample-apps/angular-chat/src/app/app.component.ts @@ -14,11 +14,13 @@ export class AppComponent { userId: string = '' chatRoomId: string messages$: Observable<ChatMessage[]> + directory$: Observable<string[]> messageBuff: string constructor(private messaging: MessagingService) {} ngOnInit() { this.messaging.init() + this.directory$ = this.messaging.getDirectory() } sendMessage() { @@ -26,7 +28,7 @@ export class AppComponent { } async makeChatRoom() { - this.chatRoomId = await this.messaging.makeChatRoom(this.userId) + this.chatRoomId = await this.messaging.makeChatRoom() this.messages$ = this.messaging.getChatRoom(this.chatRoomId) } } |