Skip to content

Commit

Permalink
example: try out events v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sebkolind committed Nov 26, 2023
1 parent 9affc52 commit 83b5c63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 3 additions & 5 deletions example/components/todo/item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ const TodoItem = {
<button>Remove</button>
</li>
`,
setup({ query, state }) {
setup({ query, state, parent }) {
const remove = query('button')

console.log('setup todo-item', state)

remove.on('click', function ({ state }) {
console.log('remove', state)
remove.on('click', function () {
parent.events.delete(state.id)
})
}
}
Expand Down
5 changes: 5 additions & 0 deletions example/components/todo/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ const TodoList = {
<todo-item></todo-item>
</ul>
`,
events: {
delete(id, { state }) {
state.items = state.items.filter(item => item.id !== id)
},
},
setup({ query, state }) {
const item = query('todo-item')

Expand Down

0 comments on commit 83b5c63

Please sign in to comment.