dart-archive / observe

Support for marking objects as observable, and getting notifications when those objects are mutated
https://pub.dartlang.org/packages/observe
BSD 3-Clause "New" or "Revised" License
13 stars 6 forks source link

ObservableList doesn't override clear(), which removes all the items without notifying observers #88

Closed JeromeA closed 8 years ago

JeromeA commented 8 years ago

When calling clear() on an ObservableList, the ListMixin implementation is called:

    void clear() { this.length = 0; }

This removes all the items, without notifying the observers.

This is breaking the ObservableList contract which states that the observers are notified if any items are added, removed or replaced.

jmesserly commented 8 years ago

Setting length to 0 will notify observers, right? https://github.com/dart-lang/observe/blob/8c6e8f958e6c6931215a541838d79519975d62b9/lib/src/observable_list.dart#L72

JeromeA commented 8 years ago

Oh, then it means I have a bug in my code :-(. Let me double check tomorrow, but I think you are right.

JeromeA commented 8 years ago

The problem was in my code, indeed. Sorry for the trouble, and thanks for your help!