bindAndWriteToRenderer function

void bindAndWriteToRenderer(
  1. List<Binding> bindings,
  2. BoundValueConverter converter,
  3. Expression? appViewInstance,
  4. NodeReference? renderNode,
  5. bool isHtmlElement,
  6. ViewNameResolver nameResolver,
  7. ViewStorage storage,
  8. CompileMethod targetMethod, {
  9. bool isHostComponent = false,
  10. bool calcChanged = false,
})

For each binding, creates code to update the binding.

Example: final currVal_1 = this.context.someBoolValue; if (import6.checkBinding(this._expr_1,currVal_1)) { this.renderer.setElementClass(this._el_4,'disabled',currVal_1); this._expr_1 = currVal_1; }

Implementation

void bindAndWriteToRenderer(
  List<ir.Binding> bindings,
  BoundValueConverter converter,
  o.Expression? appViewInstance,
  NodeReference? renderNode,
  bool isHtmlElement,
  ViewNameResolver nameResolver,
  ViewStorage storage,
  CompileMethod targetMethod, {
  bool isHostComponent = false,
  bool calcChanged = false,
}) {
  final dynamicMethod = CompileMethod();
  final constantMethod = CompileMethod();
  for (var binding in bindings) {
    if (binding.isDirect) {
      _directBinding(
        binding,
        converter,
        binding.source.isImmutable ? constantMethod : dynamicMethod,
        appViewInstance,
        renderNode,
        isHtmlElement,
      );
      continue;
    }
    _checkBinding(
        binding,
        converter,
        nameResolver,
        appViewInstance,
        renderNode,
        isHtmlElement,
        calcChanged,
        storage,
        dynamicMethod,
        constantMethod,
        isHostComponent);
  }
  if (constantMethod.isNotEmpty) {
    targetMethod.addStmtsIfFirstCheck(constantMethod.finish());
  }
  if (dynamicMethod.isNotEmpty) {
    targetMethod.addStmts(dynamicMethod.finish());
  }
}