1 3
import VNode, { RawNode } from './VNode';
2 3
import { generate } from './instanceId';
3
import { FiberRoot } from 'react-reconciler';
4

5
interface SpliceUpdate {
6
  path: string;
7
  start: number;
8
  deleteCount: number;
9
  items: RawNode[];
10
}
11

12 3
export default class AppContainer {
13
  context: any;
14
  root: VNode;
15 3
  updateQueue: SpliceUpdate[] = [];
16
  _rootContainer?: FiberRoot;
17

18 3
  constructor() {
19 3
    this.root = new VNode({
20
      id: generate(),
21
      type: 'root',
22
      container: this,
23
    });
24 3
    this.root.mounted = true;
25
  }
26

27 3
  requestUpdate(path: string, start: number, deleteCount: number, ...items: RawNode[]) {
28
    // ignore
29
  }
30

31 3
  applyUpdate() {
32 3
    this.context._pages.forEach((page: any) => {
33 3
      page.container.applyUpdate();
34 3
      page.modalContainer.applyUpdate();
35
    });
36
  }
37

38 3
  createCallback(name: string, fn: (...params: any) => any) {
39 0
    this.context[name] = fn;
40
  }
41

42 3
  appendChild(child: VNode) {
43 0
    this.root.appendChild(child);
44
  }
45

46 3
  removeChild(child: VNode) {
47 0
    this.root.removeChild(child);
48
  }
49

50 3
  insertBefore(child: VNode, beforeChild: VNode) {
51 0
    this.root.insertBefore(child, beforeChild);
52
  }
53 3
}

Read our documentation on viewing source code .

Loading