Permalink
Browse files

feature: ObservableList supports removeWhere

  • Loading branch information...
MikeMitterer committed Jul 17, 2015
1 parent aea9f19 commit d25c47380d3abe4eac8c1beeba592c940c26c509
Showing with 14 additions and 1 deletion.
  1. +14 −1 lib/src/observable/ObservableList.dart
@@ -126,11 +126,24 @@ class ObservableList<T> extends ListBase<T> {
}
@override
bool remove(final Object element) {
bool remove(final T element) {
_fire(new ListChangedEvent<T>(ListChangeType.REMOVE,item: element ));
return _innerList.remove(element);
}
@override
void removeWhere(bool test(final T element)) {
final List<T> itemsToRemove = new List<T>();
_innerList.forEach((final T element) {
if(test(element)) {
itemsToRemove.add(element);
}
});
itemsToRemove.forEach((final T element) => remove(element));
}
//- private -----------------------------------------------------------------------------------
void _fire(final ListChangedEvent<T> event) {

0 comments on commit d25c473

Please sign in to comment.