Closed fredkilbourn closed 9 years ago
Thanks Fred, could you do a pull request? I'm not sure it makes sense to move the "this.addEach(plus)" down to after the this.dispatchesRangeChanges(), because when observers get it, the collection wouldn't have changed yet
I didn't dig into it to actually see the code, but this.addEach(plus) seems to fire this.dispatchesRangeChanges() internally for each element it adds.
I don't actually know how to submit a pull request :confused: if you could handle integrating it that'd be great, if not let me know and I'll try to sort it out.
You should learn how to do a PR, very handy, but I'm taking care of it
Figured it out, submitted https://github.com/montagejs/collections/pull/106 which also addresses one additional issue with the length not being maintained for the collection.
Pull request was merged, closed.
The changes to the model are correct, it is just the dispatching that is not reporting those changes correctly.
Using this test code based on the api doc example:
Is currently outputting:
Note that 5 is reported to be added twice, and at the wrong index the second time and that 2,3 were removed from the model one dispatch before they were reported to be removed.
I applied this patch:
Which changes the output to: