Last active
July 5, 2020 09:42
-
-
Save MatthiasKainer/8556228e90fa44d38506c0688475fb8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pureLit("dispatch-todo", (element) => { | |
const { publish, getState } = useState(element, { todos: [] } as TodoState); | |
return html` | |
<h2>Your todos</h2> | |
<todo-add | |
@add="${(e: CustomEvent) => | |
publish({ todos: [...getState().todos, e.detail] })}" | |
></todo-add> | |
<todo-list | |
.items="${getState().todos}" | |
@remove="${(e: CustomEvent) => | |
publish({ | |
todos: [...getState().todos.filter((todo) => todo !== e.detail)], | |
})} | |
}" | |
></todo-list> | |
`; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment