Last active
August 2, 2019 05:18
-
-
Save daybrush/454501877be538d39af06eeb8c5c0f3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sync(result) { | |
const { maintained, removed, added, list } = result; | |
const prevItems = this.items; | |
const newItems = []; | |
maintained.forEach(([beforeIndex, afterIndex]) => { | |
newItems[afterIndex] = prevItems[beforeIndex]; | |
}); | |
added.forEach(i => { | |
newItems[i] = new Item(list[i]); | |
}); | |
this.items = newItems; | |
this.recaculateItems(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment