Skip to content

Commit 6c8162c

Browse files
dotansimhadarkbasic
authored andcommitted
Step 9.17: Subscribe to users
1 parent b5b1da6 commit 6c8162c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/pages/chats/new-chat.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ export class NewChatComponent implements OnInit {
4040
}
4141

4242
loadUsers(): void {
43-
this.users = this.findUsers();
43+
// Fetch all users matching search pattern
44+
const subscription = MeteorObservable.subscribe('users');
45+
const autorun = MeteorObservable.autorun();
46+
47+
Observable.merge(subscription, autorun).subscribe(() => {
48+
this.users = this.findUsers();
49+
});
4450
}
4551

4652
findUsers(): Observable<User[]> {

0 commit comments

Comments
 (0)