New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ObservableList.sublist does not return an ObservableList #13965
Comments
Added Area-Polymer, Triaged labels. |
Added this to the Later milestone. |
Added Library-Observe label. |
Removed Library-Observe label. |
we generally don't try to preserve observable-ness in all accessors, as that would greatly complicate ObservableList/Map impls. We'd need to know about every sublist, iterable, etc, and propagate change notifications. While it's a very neat idea and I support someone taking it on :-), we don't really have bandwidth. (and Object.observe in JS doesn't support it either, for similar reasons). OTOH, if we fix https://code.google.com/p/dart/issues/detail?id=16342 it will essentially work again (using dirty checking like Web UI did). Added NotPlanned label. |
This issue has been moved to dart-archive/observe#45. |
This issue was originally filed by @butlermatt
This used to work correctly in web_ui, but as I port my project over to Polymer I'm finding that ObservableList.sublist() does not return an ObservableList. I instead have to wrap the return of sublist in toObservable.
eg:
// This throws an exception
ObservableList get items {
if(_itemList.length < NUM_ROWS) return _itemList;
return _itemList.sublist(0, NUM_ROWS);
}
Uncaught Error: type 'List' is not a subtype of type 'ObservableList' of 'function result'.
// This works
ObservableList get items {
if(_itemList.length < NUM_ROWS) return _itemList;
return toObservable(_itemList.sublist(0, NUM_ROWS));
}
The text was updated successfully, but these errors were encountered: