Permalink
Browse files

Step 14.6: Implement subscription of uninvited users

  • Loading branch information...
1 parent 810f412 commit e8766a44540db5ad67069ce8915a8e2d77a5b030 @kamilkisiela kamilkisiela committed with DAB0mB Sep 23, 2016
Showing with 18 additions and 0 deletions.
  1. +18 −0 client/imports/app/parties/party-details.component.ts
@@ -1,5 +1,6 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
+import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { Meteor } from 'meteor/meteor';
import { MeteorObservable } from 'meteor-rxjs';
@@ -8,6 +9,8 @@ import 'rxjs/add/operator/map';
import { Parties } from '../../../../both/collections/parties.collection';
import { Party } from '../../../../both/models/party.model';
+import { Users } from '../../../../both/collections/users.collection';
+import { User } from '../../../../both/models/user.model';
import template from './party-details.component.html';
@@ -20,6 +23,8 @@ export class PartyDetailsComponent implements OnInit, OnDestroy {
paramsSub: Subscription;
party: Party;
partySub: Subscription;
+ users: Observable<User>;
+ uninvitedSub: Subscription;
constructor(
private route: ActivatedRoute
@@ -38,6 +43,18 @@ export class PartyDetailsComponent implements OnInit, OnDestroy {
this.partySub = MeteorObservable.subscribe('party', this.partyId).subscribe(() => {
this.party = Parties.findOne(this.partyId);
});
+
+ if (this.uninvitedSub) {
+ this.uninvitedSub.unsubscribe();
+ }
+
+ this.uninvitedSub = MeteorObservable.subscribe('uninvited', this.partyId).subscribe(() => {
+ this.users = Users.find({
+ _id: {
+ $ne: Meteor.userId()
+ }
+ }).zone();
+ });
});
}
@@ -59,5 +76,6 @@ export class PartyDetailsComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.paramsSub.unsubscribe();
this.partySub.unsubscribe();
+ this.uninvitedSub.unsubscribe();
}
}

0 comments on commit e8766a4

Please sign in to comment.