RenderContext<T extends LoadInstanceContext> constructor

RenderContext<T extends LoadInstanceContext>(
  1. int id,
  2. List<ViewControllerGenerator>? generators,
  3. EngineMonitor engineMonitor,
  4. bool debugMode,
  5. VoltronRenderBridgeManager? initRenderBridgeManager,
  6. DomHolder? initDomHolder,
  7. HashMap<int, RootWidgetViewModel>? initRootViewModelMap,
  8. RenderContextProxy _proxy,
)

Implementation

RenderContext(
  int id,
  List<ViewControllerGenerator>? generators,
  EngineMonitor engineMonitor,
  bool debugMode,
  VoltronRenderBridgeManager? initRenderBridgeManager,
  DomHolder? initDomHolder,
  HashMap<int, RootWidgetViewModel>? initRootViewModelMap,
  RenderContextProxy this._proxy,
)   : _engineMonitor = engineMonitor,
      _engineId = id {
  /// step 1, create renderBridgeManager for ffi
  _renderBridgeManager = initRenderBridgeManager ?? VoltronRenderBridgeManager(id);

  /// don't forget to bind current renderContext
  _renderBridgeManager.bindRenderContext(this);

  /// step 2, make sure workerManagerId is valid, use old value when reload
  _renderBridgeManager.initRenderApi();

  /// step 3, make sure dom holder is valid, use old value when reload
  if (debugMode && initDomHolder != null) {
    _domHolder = initDomHolder;
    LogUtils.dBridge('reuse dom manager id:${_domHolder.id}');
  } else {
    var domInstanceId = _renderBridgeManager.createDomInstance();
    _domHolder = DomHolder(domInstanceId);
    LogUtils.dBridge('create dom manager id:$domInstanceId');
  }

  /// don't forget to bind current renderContext
  _domHolder.bindRenderContext(this);

  /// step 4, create renderManager and virtualNodeManager
  _renderManager = RenderManager(this, generators);
  _virtualNodeManager = VirtualNodeManager(this);

  /// step 5, is reload, add all old rootViewModel
  if (initRootViewModelMap != null && initRootViewModelMap.isNotEmpty) {
    _rootViewModelMap.addAll(initRootViewModelMap);
  }
}