Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Fix Emit Decorator with multiple arguments #306

Merged
merged 1 commit into from
Apr 24, 2020

Conversation

mugi-uno
Copy link
Contributor

@mugi-uno mugi-uno commented Mar 18, 2020

When using Emit with multiple arguments, it will not work properly.
Maybe because the arguments are passed as an array

b9f0ba8#diff-a542f5e3653e6b2d1bd03489368849b9R269

@mugi-uno mugi-uno changed the title Fix Emit Decorator with multiple argments Fix Emit Decorator with multiple arguments Mar 18, 2020
@WolfgangKurz
Copy link

WolfgangKurz commented Mar 31, 2020

I think

this.$emit(emitName, returnValue)

should pass args together like below

this.$emit(emitName, returnValue, ...args)

Isn't it?

@mugi-uno
Copy link
Contributor Author

@WolfgangKurz
Yes, that pattern also needed to be corrected.

How about this?
5238ee8

@WolfgangKurz
Copy link

Yes, we need args anyway, and that solution also very good.

Thanks for your response and fixing.

Copy link
Owner

@kaorun343 kaorun343 left a comment

Choose a reason for hiding this comment

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

Thanks for your PR!!!
Could you fix this?

tests/Emit.spec.ts Outdated Show resolved Hide resolved
@gmoneh
Copy link
Contributor

gmoneh commented Apr 13, 2020

Hi. I don't know if you guys noticed, but PR #291 broke the emit decorator as is defined in the documentation. Now, if the function returns a value, the arguments received by the function are not emitted as arguments of the event, as the documentation states and as used to work before.
Does this PR fix that?

@mugi-uno
Copy link
Contributor Author

Yes. I intend to do so.

At least the test I added in this PR should work with code prior to #291.

@kaorun343 kaorun343 merged commit 0babfc3 into kaorun343:master Apr 24, 2020
@MrJmpl3
Copy link
Contributor

MrJmpl3 commented Sep 14, 2020

Nice work everyone, I really forgot that the arguments went along with the $emit.

Sorry about the problems.

PD: I think in testing, missing when you have a one argument and return that argument only (That is why I created the PR #291 ).

@Component
class ChildComponent extends Vue {
 count = 0

 @Emit()
 count(n: number) {
  return n;
 }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants