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

[3.2.2] Setting an async belongsTo triggers bindings but is not available through get #5555

Closed
miketervela opened this issue Aug 4, 2018 · 6 comments

Comments

@miketervela
Copy link

twiddle here:
https://ember-twiddle.com/9fd0a5406cd997a692ae5f4d2fb3f613?openFiles=templates.application.hbs%2C

I have a model of type 'dynamic-model' that has an array of native fields and a schema that has its own array of fields. 'dynamic-model' has a computed property to merge the two arrays together. When I call model.set('schema', schema), the computed property fires - but when it calls this.get('schema'), schema is not available.

I can, however, call this.belongsTo('schema').value() and access the newly set schema there.

this.get('schema') worked in 3.1 and earlier versions, as you can verify with the twiddle above.

dynamic-model in the twiddle has two different 'merged' properties - you can see the results of each one by clicking 'Add schema to model' and then click the respective 'View Merged by xxx' button.

You can set and clear the field multiple times to verify the behavior.

@runspired
Copy link
Contributor

I believe this is related to #5562

@runspired
Copy link
Contributor

runspired commented Aug 9, 2018

I can confirm that this is fixed in 3.2.1 and 3.3.1: the twiddle was using 3.2.0

@miketervela
Copy link
Author

miketervela commented Aug 17, 2018

Edit: The current iteration of this issue may be tied to some special handling of ours, so this may well be a local issue:

I won't reopen it, since I can't prove it in a twiddle, but I'm still seeing this in both 3.2.1 and 3.3.1 - ie, setting an async:false belongsTo triggers observers on that belongsTo, but the value is not there through 'get', just through belongsTo().value()

@runspired
Copy link
Contributor

@miketervela there is an issue with observers which is fixed on master when links are included for relationships. It’ll get backported but hasn’t been yet. Worth checking master.

@miketervela
Copy link
Author

@runspired That didn't actually solve my problem - if I get a chance this weekend I'll try creating a small project without anything custom and see if I can recreate

@miketervela
Copy link
Author

Another update: 3.40-beta.3 solves my non-async set/oberserves/get issue for hasMany's, but the exact same problem still remains for belongsTo

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

2 participants