var lesson = {
	files: [
		{
			name: "main",
			content: "import { render } from 'solid-js/web';\nimport { createSignal, createMemo } from 'solid-js';\n\nfunction fibonacci(num) {\n  if (num <= 1) return 1;\n\n  return fibonacci(num - 1) + fibonacci(num - 2);\n}\n\nfunction Counter() {\n  const [count, setCount] = createSignal(10);\n  const fib = () => fibonacci(count());\n\n  return (\n    <>\n      <button onClick={() => setCount(count() + 1)}>Count: {count()}</button>\n      <div>1. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>2. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>3. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>4. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>5. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>6. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>7. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>8. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>9. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>10. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n    </>\n  );\n}\n\nrender(() => <Counter />, document.getElementById('app'))\n"
		}
	]
};
var solved = {
	files: [
		{
			name: "main",
			content: "import { render } from 'solid-js/web';\nimport { createSignal, createMemo } from 'solid-js';\n\nfunction fibonacci(num) {\n  if (num <= 1) return 1;\n\n  return fibonacci(num - 1) + fibonacci(num - 2);\n}\n\nfunction Counter() {\n  const [count, setCount] = createSignal(10);\n  const fib = createMemo(() => fibonacci(count()));\n\n  return (\n    <>\n      <button onClick={() => setCount(count() + 1)}>Count: {count()}</button>\n      <div>1. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>2. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>3. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>4. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>5. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>6. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>7. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>8. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>9. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n      <div>10. {fib()} {fib()} {fib()} {fib()} {fib()}</div>\n    </>\n  );\n}\n\nrender(() => <Counter />, document.getElementById('app'))\n"
		}
	]
};
var markdown = "Most of the time, composing derived signals is sufficient. However, it is sometimes beneficial to cache values in order to reduce duplicated work. We can use memos to evaluate a function and store the result until its dependencies change. This is great for caching calculations for effects that have other dependencies and mitigating the work required for expensive operations like DOM node creation.\n\nMemos are both an observer, like an effect, and a read-only signal. Since they are aware of both their dependencies and their observers, they can ensure that they run only once for any change. This makes them preferable to registering effects that write to signals. Generally, what can be derived, should be derived.\n\nCreating a Memo is as simple as passing a function to `createMemo`, imported from `solid-js`. In the example, recalculating the value gets increasingly more expensive with each click. If we wrap it in `createMemo`, it recalculates only once per click:\n\n```jsx\nconst fib = createMemo(() => fibonacci(count()));\n```\nPlace a `console.log` inside the `fib` function to confirm how often it runs:\n```jsx\nconst fib = createMemo(() => {\n  console.log(\"Calculating Fibonacci\");\n  return fibonacci(count());\n});\n```\n";
var introduction_memos = {
	lesson: lesson,
	solved: solved,
	markdown: markdown
};

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