Skip to content

Instantly share code, notes, and snippets.

@xthecapx
Last active October 11, 2018 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xthecapx/5cacdbfc41e5abdcdb3097a8c99c9dbf to your computer and use it in GitHub Desktop.
Save xthecapx/5cacdbfc41e5abdcdb3097a8c99c9dbf to your computer and use it in GitHub Desktop.
import { perfume } from 'src/app/perfume';
import { PerfumeAfterViewInit } from 'perfume.js/angular';
@Component({
selector: 'ngfor-perfomance',
template: `
<ul>
<li *ngFor="let d of data; let l = last; let f = first;">
<span *ngIf="f">{{ngForCallback(true)}}</span>
{{d.name}}
<span *ngIf="l">{{ngForCallback(false)}}</span>
</li>
</ul>
`
})
@PerfumeAfterViewInit('TestingComponent')
export class TestingComponent {
public ngForCallback(value) {
if (value) {
perfume.getInstance().start('NgForFullLoop');
} else if (!value) {
const duration = <number>perfume.getInstance().end('NgForFullLoop');
perfume.getInstance().log("NgForFullLoop took: ", duration);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment