Replies: 2 comments 5 replies
-
@wheatjs Thanks for drafting this! Guess we should have this for a long time but I didn't figure out a clear way to state them out. Later once we finalize the details, we could have it as a guide in our docs. A few feedback:
And also a few more guidelines that come to my mind:
|
Beta Was this translation helpful? Give feedback.
5 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was thinking it would be a good idea if we created some guidelines for standardizing functions across vueuse. For example due to some oversights when I wrote
useMediaControls
we now have some issues like in #514. So I was thinking it would be a good idea to have some guidelines for common patterns. Here are some of my ideas for a few rules;Two-Way data flow: If a property can be updated in both directions, from the function and when using the function, then it should be returned from the object.
Don't
Do
One-way data flow: If a property is only able to be configured from the outside, then it should be a config option
Don't
Do
Controls:
If a function is often used without controls, it is preferable to provide a controls option as introduced here feat!: introduce
controls
option #362.Don't
Do
If it is likely that a function will use controls, prefer just to return the controls without the need for the
controls
option.Don't
Do
These are just a few ideas I had to help better align all the functions. Of course this has the potential to introduce quite a few breaking changes. The rules I listed are probably not perfect, but I think they provide a decent starting point.
@vueuse/collaborators
Beta Was this translation helpful? Give feedback.
All reactions