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

Review event function closures #8

Open
andyhasit opened this issue Oct 18, 2020 · 0 comments
Open

Review event function closures #8

andyhasit opened this issue Oct 18, 2020 · 0 comments

Comments

@andyhasit
Copy link
Owner

andyhasit commented Oct 18, 2020

Currently when we use :onXYZ:

<button :onClick=".btnClicked">

The babel plugin creates a closure around view.btnClicked(e, w):

p.__bv = function (view, prototype) {
  view.dom = {
    '_1_': view.__gw([0]).on('click', function (e, w) {
      view.btnClicked(e, w);
    })
  };
};

Whereas we could cut out the closure:

p.__bv = function (view, prototype) {
  view.dom = {
    '_1_': view.__gw([0]).on('click', view.btnClicked)
  };
};

But we need to make sure we can still cater for arguments like a basic onClick:

<button :onClick=".btnClicked('hello')">

Perhaps conditionally determine whether this is happening and cut out the closure if not needed?

See:

const buildEventCallback = (statement) => {

@andyhasit andyhasit changed the title Review event function binding Review event function closures Oct 18, 2020
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

No branches or pull requests

1 participant