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

Broken live-binding with can.compute if compute is updated with a can.Construct #638

Closed
colinexl opened this issue Jan 2, 2014 · 3 comments
Milestone

Comments

@colinexl
Copy link

colinexl commented Jan 2, 2014

The first commit that shows the broken behavior is 3c386da

Here's a fiddle: http://jsfiddle.net/qYdwR/1182/

Before, we initialized an empty compute by using

can.compute()

Then after some async loading operations are done, it'll update the compute by calling passing in a new Construct with data:

can.compute(new ConstructOfSomeSort(data))

This would then cause the Mustache view to update itself due to live-binding.

However, after this commit, the Mustache doesn't update itself anymore. I dug around briefly and it looks like the "computed" function in compute.js is no longer being called after the can compute update.

I believe this issue is happening in the latest CanJS2 as well.

@ghost ghost assigned andykant Jan 3, 2014
@andykant
Copy link
Contributor

andykant commented Jan 3, 2014

I've tested this a bit further, and this is an issue whenever the compute's value starts as undefined. It doesn't matter what type of new object you set it to (not can.Construct-specific)

@andykant
Copy link
Contributor

andykant commented Jan 3, 2014

In the meantime, here's a workaround... Initialize your empty can.compute with can.compute(null).

@colinexl
Copy link
Author

colinexl commented Jan 3, 2014

@andykant Your solution worked perfectly and thanks for getting down to the root cause.

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