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

Deprecation guide addition for Ember.Binding(s) that use connect #13912

Closed
toranb opened this issue Jul 27, 2016 · 9 comments
Closed

Deprecation guide addition for Ember.Binding(s) that use connect #13912

toranb opened this issue Jul 27, 2016 · 9 comments

Comments

@toranb
Copy link
Contributor

toranb commented Jul 27, 2016

Today I noticed the ember 2.7 deprecation for Ember.Binding and was curious what I should do in this situation.

initialize: Ember.on("init", function() {
  Ember.Binding.from("model." + field).to("fieldName").connect(this);
})

I assumed it was a simple defineProperty inside the init but I'm not having the same luck in ember 1.13

initialize: Ember.on("init", function() {
  Ember.defineProperty(this, "fieldName", Ember.computed("model." + field, function() {
    return this.get("model." + field);
  }));
})

If I can find a good solution I'll gladly submit a PR to the guides for others who have this same situation. Thank you in advance!

@rwjblue
Copy link
Member

rwjblue commented Jul 27, 2016

Can you whip up an ember-twiddle or JSBin to demo the issue?

@mike-north
Copy link
Contributor

mike-north commented Jul 27, 2016

We really need some in-depth material here to ease deprecation-fixing pain. Here's the error message users will get

Error: `Ember.Binding` is deprecated. Consider using an `alias` computed property instead.

It offers no clue as to what property on what component was the offender. One potential approach to track this down is:

  1. Set a conditional breakpoint at this assert, with the breakpoint condition matching the assert condition
  2. When the breakpoint is hit, jump up a couple frames in the stack until you find the offending property key
  3. git grep for the property key

I would not assume that most beginner/intermediate developers would immediately realize to take this approach (or know any approach to take, for that matter).

@pixelhandler
Copy link
Contributor

@mike-north great idea regarding giving an indication of what property the binding is associated with in the deprecation warning message.

@pixelhandler
Copy link
Contributor

@toranb regarding 1.13 I don't expect any change but understand your app may be using it so leaning toward a upgradable solution makes sense. As Robert mentioned an example using an ember-twiddle.com or a git repo would be great, and of source help with working on what could be added to the guides.

@toranb
Copy link
Contributor Author

toranb commented Jul 27, 2016

@rwjblue @pixelhandler agreed :) I'm planning to carve out some time this week to create a solid twiddle showing this in action. Thanks again!

@rwjblue
Copy link
Member

rwjblue commented Jul 27, 2016

I submitted #13920 to make the deprecation message more helpful in tracking down where a binding is being used.

@toranb
Copy link
Contributor Author

toranb commented Jul 28, 2016

Well the good news - I've got a twiddle to prove those should be identical in behavior. The bad news is I think I've found a bug in my code :)

I can't reproduce this issue w/ twiddle for reasons unrelated to this Ember.Binding deprecation. For now I'll leave you with this twiddle and if I do find something broken* I'll be sure to report it

https://ember-twiddle.com/2ab7883202dc9ff99f5bd2a04ce4e487?fileTreeShown=false&openFiles=components.validation-component.js

*in the near future

@toranb toranb closed this as completed Jul 28, 2016
@toranb toranb reopened this Jul 29, 2016
@toranb
Copy link
Contributor Author

toranb commented Jul 29, 2016

@rwjblue @pixelhandler so I've got the ability to see this breaking now and after reading some older commits in ember it seems that with connect I'm able to observe changes to the actual object but without "connect" it doesn't appear to fire the computed in the same way

2b28b20

screen shot 2016-07-28 at 7 00 45 pm

I've got this in a public addon if anyone is willing to look at it - it doesn't appear (on the surface) to be a problem with my code because I actually rely on that behavior (from the connect w/ Ember.Binding)

https://github.com/toranb/ember-cli-simple-validation/blob/master/addon/components/validation-error-field.js#L20

@toranb
Copy link
Contributor Author

toranb commented Jul 29, 2016

@rwjblue @pixelhandler and ... ignore me again! Went full out and landed a green build deprecation free :)

https://github.com/toranb/ember-cli-simple-validation/pull/23/files

@toranb toranb closed this as completed Jul 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants