Navigation Menu

Skip to content

Commit

Permalink
Step 13.2: Define options and use it in the subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela authored and dotansimha committed Nov 27, 2016
1 parent f741f64 commit 315840b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions client/imports/app/parties/parties-list.component.ts
Expand Up @@ -8,17 +8,36 @@ import { Party } from '../../../../both/models/party.model';

import template from './parties-list.component.html';

interface Pagination {
limit: number;
skip: number;
}

interface Options extends Pagination {
[key: string]: any
}

@Component({
selector: 'parties-list',
template
})
export class PartiesListComponent implements OnInit, OnDestroy {
parties: Observable<Party[]>;
partiesSub: Subscription;
pageSize: number = 10;
curPage: number = 1;
nameOrder: number = 1;

ngOnInit() {
this.parties = Parties.find({}).zone();
this.partiesSub = MeteorObservable.subscribe('parties').subscribe();
const options: Options = {
limit: this.pageSize,
skip: (this.curPage - 1) * this.pageSize,
sort: { name: this.nameOrder }
};

this.partiesSub = MeteorObservable.subscribe('parties', options).subscribe(() => {
this.parties = Parties.find({}).zone();
});
}

removeParty(party: Party): void {
Expand Down

0 comments on commit 315840b

Please sign in to comment.