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 the trigger function #17

Merged
merged 1 commit into from
Aug 30, 2021
Merged

Add the trigger function #17

merged 1 commit into from
Aug 30, 2021

Conversation

gaku-sei
Copy link
Contributor

Implements https://react-hook-form.com/api/useform/trigger/

I used @send external instead of just adding it to the record to have more flexibility with no runtime costs. The API is a bit less consistent but more flexible. We could refactor records to use this technic too 😕

@gaku-sei gaku-sei changed the title feat(trigger): Add the trigger function Add the trigger function Aug 26, 2021
Copy link
Contributor

@infothien infothien left a comment

Choose a reason for hiding this comment

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

THis will work but I just havent faced the usecase for it yet 🤔 , I will wait to check the usecase for it in ATS

@gaku-sei
Copy link
Contributor Author

It's rather simple, the 2 dates for interviews must be before/after the other one, so I need to revalidate both date on blur 😄

@send external triggerMultiple: (t, array<string>) => unit = "trigger"

@send
external triggerAndFocus: (t, string, @as(json`{ shouldFocus: true }`) _) => unit = "trigger"
Copy link

Choose a reason for hiding this comment

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

why did we have to compile the string into the json here? Based on the provided example in the react hook form docs, this doesn't look to be json trigger('name', { shouldFocus: true })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's just the way to "inject" valid json value into js from rescript.

Also, keep in mind a json value is basically.... an object in js 😄

Copy link

@vtrofin vtrofin left a comment

Choose a reason for hiding this comment

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

looks good, thank you @gaku-sei.

@vtrofin
Copy link

vtrofin commented Aug 26, 2021

I'm really curious to see the finished example on how the trigger will help in this case, for targetNumbers i used a more rudimentary approach to validate dates so that one is after the other.

@infothien
Copy link
Contributor

Like Victor mentioned @gaku-sei -san, For me I do feel the way that @vtrofin approached is just enough for us :))) but I might miss sth

@gaku-sei gaku-sei merged commit afdfdc9 into main Aug 30, 2021
@gaku-sei gaku-sei deleted the add-trigger branch August 30, 2021 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants