Skip to content

Add update method for model updates #34

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

Merged
merged 6 commits into from
Jun 1, 2019
Merged

Conversation

dfcook
Copy link
Collaborator

@dfcook dfcook commented Jun 1, 2019

Add update method to handle form updates without having to call updateState

@dfcook
Copy link
Collaborator Author

dfcook commented Jun 1, 2019

references #22

@dfcook dfcook requested a review from afontcu June 1, 2019 16:43
@afontcu
Copy link
Member

afontcu commented Jun 1, 2019

Looks good!

This made me wonder about the use cases for fireEvent.input or fireEvent.change - now that fireEvent.update handles everything (am I right?).

Should then fireEvent.update be the default way to go when interacting with inputs? It's great that it handles v-model, but I'm a bit torn that the API differs a bit from the standard events (input, change).


case 'SELECT':
elem.value = value
await fireEvent.change(elem)
Copy link
Member

Choose a reason for hiding this comment

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

quick question! Should this line return, instead of await? If not, why does it need to be different?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I missed that, updated now.

WRT change and input, I hadn't considered that update may replace them all. I would rather expose them and allow the user the choice of which to use than deprecate them. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

This actually leads me to another question...

I feel that just writing .input or .change, like the native events, makes a lot of sense. And it would be quite weird if fireEvent.input only worked in certain cases (when v-model is not used).

So... what if input and change would handle v-model properly, instead of creating a new event? Would it be hard?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could mask input or change, however we're still moving away from what is the idiomatic usage and taking away options from the end user (to use input or change as they are natively).

I'm not sure if there is an ideal solution here tbh, although I think update as it is here is probably the most flexible solution.

Copy link
Member

Choose a reason for hiding this comment

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

You are right. Also adding a method is a non breaking change, while modifying the implementation of .input and .change might be. Let's add the update method and see how it goes!

Copy link
Member

@afontcu afontcu left a comment

Choose a reason for hiding this comment

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

Looks great!

@dfcook dfcook merged commit 701f973 into master Jun 1, 2019
@dfcook dfcook deleted the issues/22-add-update-method branch June 1, 2019 20:05
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.

2 participants