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

feat(useForm): Form state management and rule validation #1594

Closed
wants to merge 8 commits into from

Conversation

LittleSound
Copy link
Contributor

@LittleSound LittleSound commented May 12, 2022

Description

This draft was made for issue #1590, which is meant to make a utility function useForm to simplify form manipulation.

Additional context

issue #1590

TODO:

  • Improve the functionalities
    • Use reactive type to return the form
    • For a single rule, the array can be omitted
    • Mark whether the value of the form has been modified
  • Unit tests
  • Documentations
  • Better type definations for Typescript

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@LittleSound LittleSound changed the title WIP: feat(useForm): Simplify form operations feat(useForm): Simplify form operations May 15, 2022
@LittleSound LittleSound changed the title feat(useForm): Simplify form operations feat(useForm): Form state management and rule validation May 15, 2022
@LittleSound LittleSound marked this pull request as ready for review May 15, 2022 08:54
@antfu
Copy link
Member

antfu commented May 16, 2022

This is a quite complex topic to solve and ppl might have different preferences in using it. Instead of having the logic inside of @vueuse/core, I think having it as a separate package would better help it to iterate and experiment on different API designs. I'd suggest you create one of your own to experiment with it. Later on, if it turns out great, I am happy to provide feedback on it and maybe move it to something like @vueuse/form like our other packages. Thanks for your contribution.

@antfu antfu closed this May 16, 2022
@LittleSound
Copy link
Contributor Author

This is a quite complex topic to solve and ppl might have different preferences in using it. Instead of having the logic inside of @vueuse/core, I think having it as a separate package would better help it to iterate and experiment on different API designs. I'd suggest you create one of your own to experiment with it. Later on, if it turns out great, I am happy to provide feedback on it and maybe move it to something like @vueuse/form like our other packages. Thanks for your contribution.

Can you give some advice on how to conduct this experiment. I can use it in my own project, but I don't know if it's enough for an experiment?

@okxiaoliang4
Copy link
Member

Maybe you need this? #1497

@antfu
Copy link
Member

antfu commented May 16, 2022

I think at the first step you could publish the package as-is and collect feedback on how the APIs work in the real world.

It would also be great if you can do a simple comparison with existing solutions in the package's README and show why this version stands out / or what's strengths of it.

@LittleSound
Copy link
Contributor Author

Maybe you need this? #1497

I didn't find this useAsyncValidator in my previous search, It may have something to do with the search terms I use
It seems to be doing the same thing as my useForm, does this mean that my useForm is not needed, I am confused

Maybe my submission of issue #1590 didn't get much attention and made me misjudge whether vueuse needed this feature?

@okxiaoliang4
Copy link
Member

in #1497 is dependent on async-validator. If you think async-validator does not meet your needs or don't want other dependent you can refer to antfu's comments.

@LittleSound
Copy link
Contributor Author

I think I'll finish useForm because I like the way I designed the implementation myself and want it to be used in projects.

@SnowingFox
Copy link

SnowingFox commented May 19, 2022

I think I'll finish useForm because I like the way I designed the implementation myself and want it to be used in projects.

Maybe you can join the vue-use-form, i had decide to rewrite the main logic. if you have interested in it, i can invite u

@LittleSound
Copy link
Contributor Author

I think at the first step you could publish the package as-is and collect feedback on how the APIs work in the real world.

It would also be great if you can do a simple comparison with existing solutions in the package's README and show why this version stands out / or what's strengths of it.

I used this weekend to build the slimeform repository, and I will continue to refine it later

https://github.com/LittleSound/slimeform

@SnowingFox
Copy link

I think at the first step you could publish the package as-is and collect feedback on how the APIs work in the real world.
It would also be great if you can do a simple comparison with existing solutions in the package's README and show why this version stands out / or what's strengths of it.

I used this weekend to build the slimeform repository, and I will continue to refine it later

https://github.com/LittleSound/slimeform

I'm looking forward to your form lib

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.

None yet

4 participants