Skip to content

Commit

Permalink
Step 14.6: Implement subscription of uninvited users
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela authored and dotansimha committed Nov 27, 2016
1 parent fdf6f2c commit 94c29e7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 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';
Expand All @@ -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';

Expand All @@ -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
Expand All @@ -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();
});
});
}

Expand All @@ -59,5 +76,6 @@ export class PartyDetailsComponent implements OnInit, OnDestroy {
ngOnDestroy() {
this.paramsSub.unsubscribe();
this.partySub.unsubscribe();
this.uninvitedSub.unsubscribe();
}
}

0 comments on commit 94c29e7

Please sign in to comment.