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

fix: do not wrap registering event listeners under effect #27

Merged
merged 5 commits into from
Dec 2, 2023

Conversation

ydcjeff
Copy link
Contributor

@ydcjeff ydcjeff commented Dec 1, 2023

Before:

  _effect(() => {
    _on(n7, "click", _ctx.inc);
  });
  _effect(() => {
    _on(n8, "click", _ctx.dec);
  });

After:

  _on(n7, "click", _ctx.inc);
  _on(n8, "click", _ctx.dec);

Copy link

github-actions bot commented Dec 1, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 87.9 kB 33.4 kB 30.2 kB
runtime-vapor.global.prod.js 15.6 kB 5.81 kB 5.32 kB
vue-vapor.global.prod.js 47.4 kB (-3 B) 15.8 kB (+5 B) 14.3 kB (+4 B)
vue.global.prod.js 144 kB 52.4 kB 46.9 kB

Usages

Name Size Gzip Brotli
createApp 48.6 kB 19 kB 17.4 kB
createSSRApp 51.8 kB 20.3 kB 18.6 kB
defineCustomElement 50.9 kB 19.8 kB 18.1 kB
vapor 15.5 kB 5.81 kB 5.33 kB
overall 61.9 kB 23.9 kB 21.8 kB

Copy link
Member

@sxzz sxzz left a comment

Choose a reason for hiding this comment

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

event handler could be changed, so effect is necessary.

@ydcjeff
Copy link
Contributor Author

ydcjeff commented Dec 2, 2023

@sxzz Do you mean reactive event handler?

@sxzz
Copy link
Member

sxzz commented Dec 2, 2023

@ydcjeff Yes

@ydcjeff
Copy link
Contributor Author

ydcjeff commented Dec 2, 2023

Interesting! I didn't happen to see in the Vue docs tho.

@ydcjeff
Copy link
Contributor Author

ydcjeff commented Dec 2, 2023

I tried reactive event handler in the Vue SFC playground, and found that Vue wraps that handler with inline function.

    onClick: _cache[0] || (_cache[0] = (...args) => (handler.value && handler.value(...args)))

So I still think we do not need wrap under effect.

@autofix-troubleshooter
Copy link

Hi! I'm the autofix logoautofix.ci troubleshooter bot.

It looks like you correctly set up a CI job that uses the autofix.ci GitHub Action, but the autofix.ci GitHub App has not been installed for this repository. This means that autofix.ci unfortunately does not have the permissions to fix this pull request. If you are the repository owner, please install the app and then restart the CI workflow! 😃

@sxzz sxzz merged commit c7cd2e4 into vuejs:main Dec 2, 2023
3 checks passed
@ydcjeff ydcjeff deleted the fix/pure-on branch December 2, 2023 22:44
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.

5 participants