refactor(benchmarks): add index_aot
to support AoT bootstrap. (#12105)
Note: This only make sure it can compile the AoT version, but does not yet use it in e2e tests.
This commit is contained in:
32
modules/benchmarks/src/tree/ng2_switch/init.ts
Normal file
32
modules/benchmarks/src/tree/ng2_switch/init.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import {ApplicationRef, NgModuleRef} from '@angular/core';
|
||||
|
||||
import {bindAction, profile} from '../../util';
|
||||
import {buildTree, emptyTree} from '../util';
|
||||
|
||||
import {AppModule, TreeComponent} from './tree';
|
||||
|
||||
export function init(moduleRef: NgModuleRef<AppModule>) {
|
||||
var tree: TreeComponent;
|
||||
var appRef: ApplicationRef;
|
||||
|
||||
function destroyDom() {
|
||||
tree.data = emptyTree;
|
||||
appRef.tick();
|
||||
}
|
||||
|
||||
function createDom() {
|
||||
tree.data = buildTree();
|
||||
appRef.tick();
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
const injector = moduleRef.injector;
|
||||
appRef = injector.get(ApplicationRef);
|
||||
|
||||
tree = appRef.components[0].instance;
|
||||
bindAction('#destroyDom', destroyDom);
|
||||
bindAction('#createDom', createDom);
|
||||
bindAction('#updateDomProfile', profile(createDom, noop, 'update'));
|
||||
bindAction('#createDomProfile', profile(createDom, destroyDom, 'create'));
|
||||
}
|
Reference in New Issue
Block a user