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

observing belongsTo never fires #5747

Closed
atomkirk opened this issue Nov 8, 2018 · 8 comments
Closed

observing belongsTo never fires #5747

atomkirk opened this issue Nov 8, 2018 · 8 comments

Comments

@atomkirk
Copy link

atomkirk commented Nov 8, 2018

We are stuck on Ember Data 3.1 because we have something like this:

model/payment.js

export default Model.extend({
  debitChartAccount: DS.belongsTo('chartAccount'),
})

components/payment-form.js

model.set('debitChartAccount', account)

components/payment-form.hbs

{{#chart-account-select initial=model.debitChartAccount as |choice|}}
  {{choice.name}}
{{/chart-account-select}}

components/chart-account-select.js

export default Component.extend({
  _observeInitial: on('init', observer('initial', function() {
    console.log('got called')
  })),
})

For some reason _observeInitial is not getting called when I do model.set('debitChartAccount', account)

I tried really hard to make a simple app that reproduced this and I couldn't so there must be something specific with my app going on. But this worked find in 3.1 and stopped working in 3.2 (with no changes to my app outside of ember init changes).

Is there any advice you can offer to help me reproduce errors like this? Are there any changes in 3.1 -> 3.2 that stand out to you as a possible cause?

@runspired
Copy link
Contributor

There is a PromiseProxy for the relationship because it is async. We used to blow away the proxy too often, now the proxy is relatively stable and only blown away when absolutely needed. I don't know for sure that this is the issue, but we should be notifying the property regardless.

@atomkirk
Copy link
Author

atomkirk commented Nov 8, 2018

Any ideas how I can test if thats the issue? I even called

model.set('debitChartAccount', account)
model.notifyPropertyChange('debitChartAccount')

and the observer STILL didn't fire. Very strange. Again, this worked on 3.1 and I changed nothing except the ember-data version to 3.2

@runspired
Copy link
Contributor

The more I think about this, the more I think we need to return to an unstable proxy for belongsTo bc it's either that or it is likely that when updating a belongsTo we also need to invalidate every watched key to deal with how the referential comparison prevents the changes from propagating deeper into template hierarchies in several commonly used (but not necessarily ideal :P ) patterns.

@runspired
Copy link
Contributor

I should be able to produce a twiddle showing the rough outlines of the issue here sans ember-data

@atomkirk
Copy link
Author

That would be SO GREAT! This is keeping us on 3.1 which is causing us to get very behind. If theres something i can do to help debug I’d love to. I can perhaps point the backend to our production servers and share our codebase with you to show you a full reproduction if the probelm… let me know

@runspired
Copy link
Contributor

@atomkirk still stuck? if so I'd love to help, if not I'd like to close.

@atomkirk
Copy link
Author

We just rewrote it. Can close

@sly7-7 sly7-7 closed this as completed May 21, 2021
@sly7-7
Copy link
Contributor

sly7-7 commented May 21, 2021

Thank you @atomkirk for the feedback. Were you able to finally upgrade ember-data too ?

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

3 participants