Skip to content

Instantly share code, notes, and snippets.

@iazel
Last active July 11, 2019 20:54
Show Gist options
  • Save iazel/46f1c51278499379a9d95c86037946b0 to your computer and use it in GitHub Desktop.
Save iazel/46f1c51278499379a9d95c86037946b0 to your computer and use it in GitHub Desktop.
Composable Reactive UI / Submit done
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