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

Fix for pr 12215 #12221

Closed
wants to merge 3 commits into from
Closed

Conversation

stefanpenner
Copy link
Member

  • actually use DK's instead of observers, and everything becomes nicer.
  • @krisselden r?
  • awesome diagram only useful to me:P
  • add test for recursive case
  • add test for crazy case with a mix of async and sync
  • add instance DKs

@stefanpenner
Copy link
Member Author

looking at these existing code, it is very likely to leak observers.

@stefanpenner
Copy link
Member Author

I think i'll take a stab at instead of using observers i'll instead dynamically add dks addDepedentKey

I just want it to use a more internally public API, rather then just pushing onto the dpKeys

// time for dinner, will look again in the AM.

@workmanw
Copy link

looking at this code, it is very likely to leak observers.

Yea that's what I was worried about. Since there really is no formal destruction for this computed property.

Thanks again for the priority :)

@stefanpenner
Copy link
Member Author

Yea that's what I was worried about. Since there really is no formal destruction for this computed property.

Thanks again for the priority :)

yup, but pushing it to DK's "just fixes it" so i'll do that in the AM

@stefanpenner
Copy link
Member Author

Alright, I am actually relatively pleased with the solution. It would be great to make the dynamic DK stuff public API somehow.

@krisselden this one needs your eyes.


cp._sortPropObservers = [];
if (sortDependentKeys) {
remove(cp._dependentKeys, sortDependentKeys);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be an method of CP? I'm hoping to reduce bookkeeping meta stuff from being sprinkled around thing, also CP descs are shared between instances, is this sym specific to this instance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CP descs are shared between instances, is this sym specific to this instance?

ya this will fail. I'll need to bring back the weakmap

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't believe this is actually an issue. Since DK changes are only taken into account after the CP invalidates. The CP code, I wrote should correctly "sync" keep it in sync.

Note, i have added additional tests to confirm

…r.computed.sort used on class with multiple instances.

// NOTE: This mechanism of dynamically adding/remove DK’s is not public API.
// I is likely something that should eventually be explored,
cp._dependentKeys.push.apply(cp._dependentKeys, sortDependentKeys);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this. Calling .property('some', 'dep', 'keys') on a CP updates its dependent keys, this is definitely public API...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rwjblue well .property replaces, it doesn't merge/append.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, good point

@stefanpenner stefanpenner force-pushed the fix-for-pr-12215 branch 2 times, most recently from 8782e45 to 71102c3 Compare August 27, 2015 18:51
@stefanpenner
Copy link
Member Author

There is still an issue with recursion. We can solve it two ways.

  1. clever code in the sort CP
  2. add the concept of an instance DK

I prefer 2 and will likely explore that after lunch.

obj2.notifyPropertyChange('sortedItems'); // invalidate to flush, to get DK refreshed
obj2.get('sortedItems'); // flush to get updated DK

obj2.set('items.firstObject.count', 9999)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semicolon

NOTE: This mechanism of dynamically adding/remove DK’s is not public API.
@stefanpenner
Copy link
Member Author

@krisselden has provided what i believe to be a failing test scenario for what i was unable to get myself: http://jsfiddle.net/mbd04xee/

I'll try and work the solution in the next few days. I have a pretty good idea how to solve it.

mmun added a commit to mmun/ember.js that referenced this pull request Feb 21, 2016
Resolves a regression in `Ember.computed.sort` that has existed since
2.0.0. The regression occurred when there were multiple instances of a
class using `Ember.computed.sort` and caused the sorted value to stop
updating.

Closes emberjs#12212.
Closes emberjs#12215.
Closes emberjs#12221.
Closes emberjs#12516.
rwjblue pushed a commit that referenced this pull request Feb 21, 2016
Resolves a regression in `Ember.computed.sort` that has existed since
2.0.0. The regression occurred when there were multiple instances of a
class using `Ember.computed.sort` and caused the sorted value to stop
updating.

Closes #12212.
Closes #12215.
Closes #12221.
Closes #12516.

(cherry picked from commit f05bd2d)
@rwjblue rwjblue deleted the fix-for-pr-12215 branch April 11, 2016 00:09
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

Successfully merging this pull request may close these issues.

5 participants