Skip to content

Commit

Permalink
Data does not repeat an extra time for every revisit if just using ha…
Browse files Browse the repository at this point in the history
…rdcoded array and no async
  • Loading branch information
steff1193 committed Oct 13, 2016
1 parent 317e697 commit 2933bd6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/imports/app/demo/demo.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ <h2>{{greeting}}</h2>

This is the available data:
<ul>
<!-- NOT A PROBLEM IF USING A HARDCODED ARRAY WITHOUT ASYNC -->
<!--li *ngFor="let item of data" -->
<li *ngFor="let item of data | async">
{{item.name}} ({{item.age}})
</li>
Expand Down
4 changes: 4 additions & 0 deletions client/imports/app/demo/demo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ import template from './demo.component.html';
})
export class DemoComponent implements OnInit {
greeting: string;
// NOT A PROBLEM IF USING A HARDCODED ARRAY WITHOUT ASYNC
// data: any[];
data: Observable<DemoDataObject[]>;

constructor(private demoDataService: DemoDataService) {
this.greeting = 'Hello Demo Component!';
}

ngOnInit() {
// NOT A PROBLEM IF USING A HARDCODED ARRAY WITHOUT ASYNC
// this.data = [{name: "Dotan", age: 25}, {name: "Liran", age: 26}, {name: "Uri", age: 30}];
this.data = this.demoDataService.getData().zone();
}
}

0 comments on commit 2933bd6

Please sign in to comment.