Skip to content

Instantly share code, notes, and snippets.

@Kelin2025
Created November 29, 2019 08:24
Show Gist options
  • Save Kelin2025/d93a43d877c2d564c8dacd3511204121 to your computer and use it in GitHub Desktop.
Save Kelin2025/d93a43d877c2d564c8dacd3511204121 to your computer and use it in GitHub Desktop.
export const NameField = createField({
view: ({ value, onChange }) => <Input value={value} onChange={onChange} />
})
export const SaveButton = createButton({
type: "save",
text: () => "Save User"
})
import { saveUser } from '~api'
import { NameField } from './0.NameField.ts'
import { SaveButton } from './1.SaveButton.ts'
const $form = createStoreObject({
name: NameField.$value
})
forward({
from: sample($form, SaveButton.pressed),
to: saveUser
})
const Form = () => {
return <form onSubmit={SaveButton.pressed}>
<NameField />
<SaveButton />
</form>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment