MCPcopy Index your code
hub / github.com/angular/angular / init

Function init

modules/benchmarks/src/hydration/init.ts:32–83  ·  view source on GitHub ↗
(appRef: ApplicationRef, insertSsrContent = true)

Source from the content-addressed store, hash-verified

30}
31
32export function init(appRef: ApplicationRef, insertSsrContent = true) {
33 let tableComponentRef: ComponentRef<TableComponent>;
34 const injector = appRef.injector;
35 const environmentInjector = injector.get(EnvironmentInjector);
36
37 let data: TableCell[][] = [];
38
39 const setInput = (data: TableCell[][]) => {
40 if (tableComponentRef) {
41 tableComponentRef.setInput('data', data);
42 tableComponentRef.changeDetectorRef.detectChanges();
43 }
44 };
45
46 function destroyDom() {
47 setInput(emptyTable);
48 }
49
50 function updateDom() {
51 data = buildTable();
52 setInput(data);
53 }
54
55 function createDom() {
56 const hostElement = document.getElementById('table')!;
57 tableComponentRef = createComponent(TableComponent, {environmentInjector, hostElement});
58 setInput(data);
59 }
60
61 function prepare() {
62 destroyDom();
63 data = buildTable();
64
65 if (insertSsrContent) {
66 // Prepare DOM structure, similar to what SSR would produce.
67 const hostElement = document.getElementById('table')!;
68 hostElement.setAttribute('ngh', '0');
69 hostElement.textContent = ''; // clear existing DOM contents
70 hostElement.appendChild(createTableDom(data));
71 }
72 }
73
74 function noop() {}
75
76 initTableUtils();
77
78 bindAction('#prepare', prepare);
79 bindAction('#createDom', createDom);
80 bindAction('#updateDom', updateDom);
81 bindAction('#createDomProfile', profile(createDom, prepare, 'create'));
82 bindAction('#updateDomProfile', profile(updateDom, noop, 'update'));
83}
84
85/**
86 * Creates DOM to represent a table, similar to what'd be generated

Callers 2

main.tsFile · 0.90
main.tsFile · 0.90

Calls 4

initTableUtilsFunction · 0.90
bindActionFunction · 0.90
profileFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…