Last active
July 11, 2019 20:54
-
-
Save iazel/46f1c51278499379a9d95c86037946b0 to your computer and use it in GitHub Desktop.
Composable Reactive UI / Submit done
This file contains hidden or 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
import { h, sc, props, onClick, ctext } from '@crui/core' | |
import { StreamBox } from '@crui/reactive/rx/box'; | |
type AddTodo = (todo: string) => void | |
const submit = (todo: StreamBox<string>, addTodo: AddTodo) => ( | |
h('button', sc([ | |
ctext('Add') | |
props({ className: 'add-todo-submit' }), | |
onClick((e) => { | |
e.preventDefault() | |
addTodo(todo.get()) | |
todo.set('') | |
}), | |
])) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment