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

Changes to closure actions' inputs no longer propagate as a change to the action value #14748

Closed
dfreeman opened this issue Dec 22, 2016 · 3 comments
Assignees

Comments

@dfreeman
Copy link
Contributor

In Ember 2.10.0 (and prior), if I had the following template and changed the value of arg, then my-component would receive that as an update to prop — meaning didUpdateAttrs would be called, any observers on prop would execute, and any computeds depending on it would invalidate.

{{my-component prop=(action 'foo' arg)}}

In Ember 2.10.1, this no longer happens (I'm guessing as a result of the fix for #14654).

In this twiddle, clicking the button updates the action input and triggers an alert in Ember 2.1.2 through 2.10.0, but doesn't if you update twiddle.json to use 2.10.1.

@chancancode
Copy link
Member

@mixonic @rwjblue is this legit? we would have to make more things lazy again, which is not amazing, but perhaps acceptable. I was under the impression that the API contract/boundrary is that we produce a function that "works".

@dfreeman
Copy link
Contributor Author

dfreeman commented Dec 22, 2016

To give a little more context, we only uncovered a single place where we were relying on the old behavior, and the change was easy to work around once we realized what was happening. Given that no one else has reported this since 2.10.1 came out, I suspect from a practical standpoint it wouldn't be a big deal if the new behavior stayed.

The reason I filed, though, is that this change seems at odds with the mental model I have for actions as component properties that happen to be functions, and the (action helper as sugar for binding a this value and possibly some parameter values. The guides around actions seem to have been shifting toward that view of things since closure actions were first introduced.

If thinking of the output from (action as just a bound version of the input function is correct, then I'd expect binding a new value for a parameter (or a new function) to produce an observably different output value, as it would if the helper were implemented in userland with Function#bind. If my mental model is just off, though, then I'm happy to just adjust and move on :)

@mixonic
Copy link
Sponsor Member

mixonic commented Mar 26, 2017

The only contract is that (action generates a function that works. No documentation describes the timing of when a new function is generated.

@dfreeman sorry if you got tripped up here. Your mental model is correct and I still think useful, however it can be so and still be slightly divergent from the implementation itself.

I'm going to close this, but please re-open if you think I've missed something. Thank you!

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

3 participants