Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target and change update handlers api #72

Merged
merged 6 commits into from
Mar 25, 2020
Merged

Add target and change update handlers api #72

merged 6 commits into from
Mar 25, 2020

Conversation

alex35mil
Copy link
Member

Fixes #68

/cc @johnhaley81

/>
```

The value of the field is exposed via `form.input` record. For extra safety, we disable all inputs during form submission using `form.submitting` property which is of boolean type. The next 2 functions are very important:
1. `form.blurEmail: unit => unit`: must be triggered from `onBlur` handler of an input field
2. `form.updateEmail: (input => input) => unit`: must be triggered from `onChange` handler of an input field. It takes a function as an argument which takes the current form `input` and must return updated `input` record.
1. `form.blurEmail: ReactEvent.Focus.t => unit`: must be triggered from `onBlur` handler of an input field
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type signature is much better! The intended use is encoded in the function type sig instead of a unit => unit

```

This runtime error happens due to [React's `SyntheticEvent` being pooled](https://reactjs.org/docs/events.html#event-pooling). Since callback gets triggered asynchronously, by the time it gets called, the event is already null'ed by React.
1. `form.blurEmail: unit => unit`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure on what we'd get back for a blur event in React Native. CC @endlo

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that in react native api there are event-less handlers exist, we shouldn't encode events in formality handlers b/c it would restrict usage only to RN handlers with events which is unnecessary limitation imo.

@johnhaley81
Copy link
Contributor

If @endlo doesn't have anything to add then this looks gtg to me

@alex35mil
Copy link
Member Author

Published 4.0.0-beta.3.

@alex35mil alex35mil merged commit f034af9 into master Mar 25, 2020
@alex35mil alex35mil deleted the target branch March 25, 2020 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update handlers API
2 participants