Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Feature: Support unidirectional dataflow syntactic sugar #15455

Open
dcherman opened this issue Nov 30, 2016 · 2 comments
Open

Feature: Support unidirectional dataflow syntactic sugar #15455

dcherman opened this issue Nov 30, 2016 · 2 comments

Comments

@dcherman
Copy link
Contributor

dcherman commented Nov 30, 2016

Similar to Angular 2's "banana in a box" syntactic sugar to support adding a one-way binding and an expression to set that one-way binding all in one shot, how would you feel about supporting something like:

<my-component ng-banana-foo="bar> which would expand internally to <my-component foo="bar" foo-changed="bar=$event">?

While the proposed syntax isn't quite as nice as the Angular2 one, I thought it might be important to not use the same syntax in order to avoid confusion between the two frameworks. With the push towards components and unidirectional dataflow since 1.5, this would be a really nice enhancement to reduce some of the verbosity associated with actually following those ideas.

@gkalpak
Copy link
Member

gkalpak commented Dec 1, 2016

I generally like the idea. (Maybe ng-bindon- would be a more suitable name though 😃)
Without giving it much thought, one thing that I am not excited about is that this will require a little extra work (sme as we do for ngAttr) for every attribute we process.

@dcherman
Copy link
Contributor Author

dcherman commented Dec 1, 2016

Yea, naming is hard. I couldn't think of an ng-bind variant that was both succinct and clear.

  • ng-autobind
  • ng-two-way

Are the two best I've got so far. Wasn't too concerned about the name in the proposal since we can bikeshed that while implementing the actual meat of the feature.

As far as any perf implications, I think that with a fairly simple modification to NG_ATTR_BINDING and collectDirectives in $compile, we can get this feature without any additional iteration of the attributes and with minimal overhead. I'll see about throwing together a proof of concept when I have some time over the next few days.

dcherman added a commit to dcherman/angular.js that referenced this issue Dec 2, 2016
In order to reduce some of the verbosity associated with conforming to the
ideas behind unidirectional data-flow, we can introduce a special
attribute syntax that will be automatically expanded in order to simulate
two-way data binding.

For example,

`<my-component ng-autobind-foo="bar">` will be expanded into
`<my-component foo="bar" foo-changed="bar = $event">`

Fixes angular#15455
dcherman added a commit to dcherman/angular.js that referenced this issue Dec 2, 2016
In order to reduce some of the verbosity associated with conforming to the
ideas behind unidirectional data-flow, we can introduce a special
attribute syntax that will be automatically expanded in order to simulate
two-way data binding.

For example,

`<my-component ng-autobind-foo="bar">` will be expanded into
`<my-component foo="bar" foo-changed="bar = $event">`

Fixes angular#15455
dcherman added a commit to dcherman/angular.js that referenced this issue Dec 2, 2016
In order to reduce some of the verbosity associated with conforming to the
ideas behind unidirectional data-flow, we can introduce a special
attribute syntax that will be automatically expanded in order to simulate
two-way data binding.

For example,

`<my-component ng-autobind-foo="bar">` will be expanded into
`<my-component foo="bar" foo-changed="bar = $event">`

Fixes angular#15455
dcherman added a commit to dcherman/angular.js that referenced this issue Dec 2, 2016
In order to reduce some of the verbosity associated with conforming to the
ideas behind unidirectional data-flow, we can introduce a special
attribute syntax that will be automatically expanded in order to simulate
two-way data binding.

For example,

`<my-component ng-bindon-foo="bar">` will be expanded into
`<my-component foo="bar" foo-change="bar=$event">`

Fixes angular#15455
dcherman added a commit to dcherman/angular.js that referenced this issue Dec 2, 2016
In order to reduce some of the verbosity associated with conforming to the
ideas behind unidirectional data-flow, we can introduce a special
attribute syntax that will be automatically expanded in order to simulate
two-way data binding.

For example,

`<my-component ng-bindon-foo="bar">` will be expanded into
`<my-component foo="bar" foo-change="bar=$event">`

Fixes angular#15455
dcherman added a commit to dcherman/angular.js that referenced this issue Dec 2, 2016
In order to reduce some of the verbosity associated with conforming to the
ideas behind unidirectional data-flow, we can introduce a special
attribute syntax that will be automatically expanded in order to simulate
two-way data binding.

For example,

`<my-component ng-bindon-foo="bar">` will be expanded into
`<my-component foo="bar" foo-change="bar=$event">`

Fixes angular#15455
dcherman added a commit to dcherman/angular.js that referenced this issue Dec 2, 2016
In order to reduce some of the verbosity associated with conforming to the
ideas behind unidirectional data-flow, we can introduce a special
attribute syntax that will be automatically expanded in order to simulate
two-way data binding.

For example,

`<my-component ng-bindon-foo="bar">` will be expanded into
`<my-component foo="bar" foo-change="bar=$event">`

Fixes angular#15455
dcherman added a commit to dcherman/angular.js that referenced this issue Dec 3, 2016
In order to reduce some of the verbosity associated with conforming to the
ideas behind unidirectional data-flow, we can introduce a special
attribute syntax that will be automatically expanded in order to simulate
two-way data binding.

For example,

`<my-component ng-bindon-foo="bar">` will be expanded into
`<my-component foo="bar" foo-change="bar=$event">`

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

Successfully merging a pull request may close this issue.

2 participants