var lesson = {
	files: [
		{
			name: "main",
			content: "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\nimport { createStore } from \"solid-js/store\";\n\nconst App = () => {\n  let input;\n  let todoId = 0;\n  const [todos, setTodos] = createSignal([])\n  const addTodo = (text) => {\n    setTodos([...todos(), { id: ++todoId, text, completed: false }]);\n  }\n  const toggleTodo = (id) => {\n    setTodos(todos().map((todo) => (\n      todo.id !== id ? todo : { ...todo, completed: !todo.completed }\n    )));\n  }\n\n  return (\n    <>\n      <div>\n        <input ref={input} />\n        <button\n          onClick={(e) => {\n            if (!input.value.trim()) return;\n            addTodo(input.value);\n            input.value = \"\";\n          }}\n        >\n          Add Todo\n        </button>\n      </div>\n      <For each={todos()}>\n        {(todo) => {\n          const { id, text } = todo;\n          console.log(`Creating ${text}`)\n          return <div>\n            <input\n              type=\"checkbox\"\n              checked={todo.completed}\n              onchange={[toggleTodo, id]}\n            />\n            <span\n              style={{ \"text-decoration\": todo.completed ? \"line-through\" : \"none\"}}\n            >{text}</span>\n          </div>\n        }}\n      </For>\n    </>\n  );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
		}
	]
};
var solved = {
	files: [
		{
			name: "main",
			content: "import { render } from \"solid-js/web\";\nimport { For } from \"solid-js\";\nimport { createStore } from \"solid-js/store\";\n\nconst App = () => {\n  let input;\n  let todoId = 0;\n  const [store, setStore] = createStore({ todos: [] })\n  const addTodo = (text) => {\n    setStore(\"todos\", todos => [...todos, { id: ++todoId, text, completed: false }]);\n  }\n  const toggleTodo = (id) => {\n    setStore(\"todos\", todo => todo.id === id, \"completed\", completed => !completed);\n  }\n\n  return (\n    <>\n      <div>\n        <input ref={input} />\n        <button\n          onClick={(e) => {\n            if (!input.value.trim()) return;\n            addTodo(input.value);\n            input.value = \"\";\n          }}\n        >\n          Add Todo\n        </button>\n      </div>\n      <For each={store.todos}>\n        {(todo) => {\n          const { id, text } = todo;\n          console.log(`Creating ${text}`)\n          return <div>\n            <input\n              type=\"checkbox\"\n              checked={todo.completed}\n              onchange={[toggleTodo, id]}\n            />\n            <span\n              style={{ \"text-decoration\": todo.completed ? \"line-through\" : \"none\" }}\n            >{text}</span>\n          </div>\n        }}\n      </For>\n    </>\n  );\n};\n\nrender(App, document.getElementById(\"app\"));\n"
		}
	]
};
var markdown = "Store 是 Solid 处理嵌套响应式给出回答。Store 是代理对象，其属性可以被跟踪，并且可以包含其他对象，这些对象会自动包装在代理中，等等。\n\n为了让事情变得简单，Solid 只为在跟踪范围内访问的属性创建底层 Signal。因此，Store 中的所有 Signal 都是根据要求延迟创建的。\n\n`createStore` 函数接收一个初始值并返回一个类似于 Signal 的读/写元组。第一个元素是只读的 store 代理，第二个元素是 setter 函数。\n\n最基础的 setter 函数用法会接收一个对象，该对象的属性将与当前状态合并。setter 函数还支持路径语法，以便我们进行嵌套更新。通过这种方式，我们仍然可以保持对响应性的控制，以及精确定位更新。\n\n> Solid 的路径语法支持多种形式，包括一些强大的语法来进行迭代和范围。有关完整的参考，请参阅 API 文档。\n\n让我们看看使用 Store 实现嵌套响应性有多容易。我们可以用这个替换我们组件的初始化代码：\n\n```js\nconst [store, setStore] = createStore({ todos: [] });\nconst addTodo = (text) => {\n  setStore('todos', (todos) => [...todos, { id: ++todoId, text, completed: false }]);\n};\nconst toggleTodo = (id) => {\n  setStore('todos', (t) => t.id === id, 'completed', (completed) => !completed);\n};\n```\n\n可以将 setter 函数配合 Store 的路径语法一起使用，setter 函数接收先前的状态并返回嵌套值的新状态。\n\n就是这样。模板的其余部分就能做出了精细的响应（在单击复选框时检查控制台）。\n";
var stores_createstore = {
	lesson: lesson,
	solved: solved,
	markdown: markdown
};

export { stores_createstore as default, lesson, markdown, solved };
