Updownquark / ObServe

Powerful observable application utilities
MIT License
1 stars 2 forks source link

Misuse of ObservableOrderedElement.takeUntil #5

Closed Updownquark closed 8 years ago

Updownquark commented 8 years ago

When ObservableOrderedElement.takeUntil is used on an external observable, the observable's firing can result in elements being completed (removed) in the order in which they were added to the collection, which may or may not be the order that they have within the collection. Regardless, this can result in errors because the ordered collection contract specifies that elements' indexes will be correct when they are removed. Indexes are not and cannot be accounted for by ObservableOrderedElement.takeUntil, so this can result in index exceptions down the line.

I have created ObservableCollection.takeUntil(Observable) to resolve this issue. The ordering is handled correctly by the ordered implementations of this method. However, there are still various places in the code that do this incorrectly.

ObservableOrderedCollection.flatten also does some sorting, which seems like overkill. I think I need to rip the sorting out of this method and make a method ObservableOrderedCollection.sort() to do sorting. The ordered flatten methods may not be able to use takeUntil() since their elements' indexes need to take previous elements in the outer collection, but these methods need to be updated to remove inner elements properly when outer elements are removed.

Updownquark commented 8 years ago

I have resolved all of these misuses.