-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Ember.arrayComputed should consider compound dependent keys #4684
Comments
After reading the source, I think I found a workaround in my case: |
@hjdivad ping. |
@searls was "this" above meant to link to something, perhaps a jsbin? does http://emberjs.jsbin.com/gafix/8/edit still exhibit the failing behaviour? I'm getting the following in the console:
|
Sorry about that. Totally lost the bin apparently. See this approach with the DK of Compare with this one with DK of |
See #5268 |
@searls I gave this thing a try today and I started by writing a failing test, which in fact doesn't fail. Could you take a look and see if anything here is different from your setup? QUnit.module('arrayComputed - compound dependent keys', {
setup: function() {
callbackItems = [];
run(function() {
obj = EmberObject.createWithMixins({
items: Ember.A([EmberObject.create({ n: 'one', m: 'two' })]),
itemsNM: arrayComputed('items.@each.{n,m}', {
addedItem: function(array, item, changeMeta, instanceMeta) {
callbackItems.push('added:' + get(item, 'n') + ':' + get(item, 'm'));
},
removedItem: function(array, item, changeMeta, instanceMeta) {
callbackItems.push('removed:' + get(item, 'n') + ':' + get(item, 'm'));
}
})
});
});
},
teardown: function() {
run(function() {
obj.destroy();
});
}
});
test("when compound keys are used, addedItem and removedItem callbacks should be called after each change", function() {
var expected, items;
items = get(obj, 'items');
run(function() {
obj.get('itemsNM');
});
run(function() {
set(items.get('firstObject'), 'n', "two");
set(items.get('firstObject'), 'm', "one");
});
expected = [
"added:one:two",
"removed:two:two",
"added:two:two",
"removed:two:one",
"added:two:one"
];
deepEqual(callbackItems, expected, "changeMeta includes previous values");
}); |
Has the SSOT branch been merged in? If so then I bet that fixed this. On Tue, Sep 23, 2014 at 6:34 PM, Piotr Sarnacki notifications@github.com
|
What's the SSOT branch? |
@searls yeah, since beta.10, but you should use beta.11. @fishermand46 It's a branch of ember data designed to fix relationship bugs and increase consistency with adding and removing relationships on both sides of the relationship. E.g. if I add or remove from one side (post.get('comments')) it should show up on the other side('comment.get('post')). It was merged in beta.10 but we had some regressions that should be fixed in beta.11. Let us know! |
Thanks for the response @fivetanley! In that case, I think my issue is unrelated to this. I think #5268 is the ticket for me. |
In attempting to work around #4681 at @mmun's suggestion I ended up with something like this, expecting two invocations of
addItem
for each item (one empty object before setupData was called and once aftercontent
was set):Ember.arrayComputed "messages.@each.content"
However, even then I was seeing two invocations, one with
content
set. But another property I needed (receivedAt
) was still not set, so I tried:Ember.arrayComputed "messages.@each.{content,receivedAt}"
And it continued to only fire twice, with
receivedAt
still being undefined both times.The text was updated successfully, but these errors were encountered: