import { jsx, jsxs, Fragment } from 'solid-jsx/jsx-runtime';

/*@jsxRuntime automatic @jsxImportSource solid-jsx*/
const toc = [];
function _createMdxContent(props) {
  const _components = Object.assign({
    p: "p",
    code: "code",
    pre: "pre",
    span: "span"
  }, props.components);
  return jsxs(Fragment, {
    children: [jsx(_components.p, {
      children: "Solid 的响应式是同步的，这意味着在任何变更后的下一行 DOM 都会更新。在大多数情况下，这完全没问题，因为 Solid 的粒度渲染只是更新在响应式系统中的传播。渲染两次无关的更改实际上并不意味着浪费性能。"
    }), "\n", jsxs(_components.p, {
      children: ["如果更改是相关的怎么办？Solid 的 ", jsx(_components.code, {
        children: "batch"
      }), " 工具函数允许将多个更改推入队列，然后在通知观察者之前同时使用它们。在批处理中更新的信号值直到批处理完成才会提交。"]
    }), "\n", jsxs(_components.p, {
      children: ["在这个例子中，我们在按钮点击时分配了两个名字，触发了渲染更新两次。单击该按钮后，可以在控制台中看到日志。因此，让我们将 ", jsx(_components.code, {
        children: "set"
      }), " 调用打包成一个批次。"]
    }), "\n", jsx(_components.pre, {
      children: jsxs(_components.code, {
        className: "hljs language-js",
        children: [" ", jsx(_components.span, {
          className: "hljs-keyword",
          children: "const"
        }), " ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "updateNames"
        }), " = (", jsx(_components.span, {
          className: "hljs-params"
        }), ") => {\n    ", jsx(_components.span, {
          className: "hljs-variable language_",
          children: "console"
        }), ".", jsx(_components.span, {
          className: "hljs-title function_",
          children: "log"
        }), "(", jsx(_components.span, {
          className: "hljs-string",
          children: "\"Button Clicked\""
        }), ");\n    ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "batch"
        }), "(", jsx(_components.span, {
          className: "hljs-function",
          children: "() =>"
        }), " {\n      ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "setFirstName"
        }), "(", jsx(_components.span, {
          className: "hljs-title function_",
          children: "firstName"
        }), "() + ", jsx(_components.span, {
          className: "hljs-string",
          children: "\"n\""
        }), ");\n      ", jsx(_components.span, {
          className: "hljs-title function_",
          children: "setLastName"
        }), "(", jsx(_components.span, {
          className: "hljs-title function_",
          children: "lastName"
        }), "() + ", jsx(_components.span, {
          className: "hljs-string",
          children: "\"!\""
        }), ");\n    })\n  }\n"]
      })
    }), "\n", jsx(_components.p, {
      children: "就是这样。现在整个变更集只会通知一次。"
    })]
  });
}
function MDXContent(props = {}) {
  const {wrapper: MDXLayout} = props.components || ({});
  return MDXLayout ? jsx(MDXLayout, Object.assign({}, props, {
    children: jsx(_createMdxContent, props)
  })) : _createMdxContent(props);
}

export { MDXContent as default, toc };
//# sourceMappingURL=lesson-d183ef26.js.map
