enyojs/enyo — pull request #584 by vtomilin (2013-12-05 22:33:06+00:00)
Title: Fixed a 'duplicate record added' exception from the Store when a collection is fetchAndReplace'd multiple times

The issue is, model instances are not removed from the Store when they are purged from a Collection with remove() or removeAll(). That causes attempts to insert duplicates into the Store when one does Collection.fetchAndReplace()(then uses the data with Collection.at()) against same remote dataset.

Why do I need to retrieve same data over again? Imagine implementation of an infinite list, based on enyo.List, backed by a Collection, which interfaces with large remote dataset A collection instance only fetches a window of that data at any given time whereby List displays that window, however, list count is set to the total number of records in the remote dataset. List's onSetupItem() is programmed in such a way, that it fetches data when needed as List is scrolled - back and forth. Which is when Collection.fetchAndReplace() may occur, retrieving previously seen data.