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

stateless directive #24

Open
francescoagati opened this issue Jul 31, 2016 · 4 comments
Open

stateless directive #24

francescoagati opened this issue Jul 31, 2016 · 4 comments
Labels

Comments

@francescoagati
Copy link

francescoagati commented Jul 31, 2016

Hi,
this is a proposal for using a static directive. actually every time a directive is used, an object is created.
My idea is:
if in the directive function is passed a function instead an object, the function is called with node element.

example

directives: {
  background:functon(node,value) {
       node.style.backgroundColor = value;
  }
}
@antonmedv
Copy link
Owner

Hi,
Yes, this is good solution. I'll try to implement it. But in this case we need to add if for each directive call. Maybe it will be better to use another syntax for stateless directive like @bg={{ }}. But it will complicate learning.

@francescoagati
Copy link
Author

Or using ::bg=
The simbol :: Is used in many lang for static methods and properties access

@francescoagati
Copy link
Author

Another syntax is better for performance instead of using if at runtime

@francescoagati
Copy link
Author

i think we can pass also state in staless directive

directives: {
  background:functon(node,state,value) {
       node.style.backgroundColor = value;
  }
}

where state can be bind,unbind,update

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

No branches or pull requests

2 participants