<script>
import { mergerinoStore } from './stores.js';
const store = mergerinoStore({ todos: [
{ done: true, text: 'make a sandwich' },
{ done: false, text: 'eat the sandwich' },
{ done: false, text: 'make another sandwich' }
] });
function toggleTodo(i, done) {
store.update({ todos: { [i]: { done } } });
}
function setTodo(i, text) {
store.update({ todos: { [i]: { text } } });
}
</script>
{#each $store.todos as todo, i}
<label>
<input
type="checkbox"
checked={todo.done}
on:change="{e => toggleTodo(i, e.target.checked)}"
>
<input
on:input="{e => setTodo(i, e.target.value)}"
value={todo.text}
>
</label>
{/each}
<pre>{JSON.stringify($store, null, ' ')}</pre>