Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

T/132: Two–way data binding between Collection instances #140

Merged
merged 11 commits into from
Mar 22, 2017
Merged

Conversation

oleq
Copy link
Member

@oleq oleq commented Mar 20, 2017

Suggested merge commit message (convention)

Feature: Two–way data binding between Collection instances. Closes ckeditor/ckeditor5#4939.

@oleq oleq requested a review from pjasiun March 20, 2017 15:12
* @protected
* @member {Map}
*/
this._bindToInternalToExternalMap = new Map();
Copy link

Choose a reason for hiding this comment

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

Can't it be a WeaMap? Does not look like a real collection more like mapping and WeaMap wound be safer for mapping because it will be cleared even if one forget to call clear. I see you iterate over this map only in tests what seems to be too deeply testing, checking internal, what is a bad smell. Can't test check only the content of collections without checking internal?

Copy link

Choose a reason for hiding this comment

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

Also, it's not clear what these variable are used for. What is external items? What is internal? A longer description would be useful since there variable seems to be essential for the binding.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll check this out. What you suggest is probably a good idea.


assertItems( collectionA, [ 4, 6, 8 ], [ [ 2, 4 ], [ 3, 6 ], [ 4, 8 ] ] );
assertItems( collectionB, [ 2, 3, 4 ], [ [ 4, 2 ], [ 6, 3 ], [ 8, 4 ] ] );
assertItems( collectionC, [ -2, -3, -4, -1000 ], [ [ 2, -2 ], [ 3, -3 ], [ 4, -4 ] ] );
Copy link

Choose a reason for hiding this comment

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

Aaa! Magic numbers. @scofalik would love it ;) But beeing serious, I wanted to write that these assertions should be split into separate assertItems and assertMapping what would make them more readable, but, as I wrote, I don't think mapping should be tested, but only the result of the mapping.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe you're right. This helped me a lot during development but shouldn't necessary remain in the tests.

@pjasiun pjasiun merged commit 6b79624 into master Mar 22, 2017
@pjasiun pjasiun deleted the t/132 branch March 22, 2017 16:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Two–way binding between Collection instances
2 participants