Split DataSource & DataSourceView
Summary: This diff is primarily cosmetic, just pushing code around to make the API more intuitive. Most importantly, DataSource was split into DataSource and DataSourceView classes, the latter being accessible through `datasource.view`. The benefit of this is two fold: 1. Conceptually it is much clearer now which operations operate on the _source_ records, and which ones on the derived _view_. 2. This will make it easier in the future to support multiple views to be based on a single data source. This refactoring also nicely found 2 cases where datasource logic and view logic were mixed. The only semantic change in this diff is that both DataSource and DataSourceView are now iterable, so that one can do a `for (const record of ds)` / `for (const record of ds.view)` Reviewed By: nikoant Differential Revision: D26976838 fbshipit-source-id: 3726e92b3c6ee3417dc66cbbe6e288797eecf70e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d73f6578a7
commit
602152665b
@@ -342,7 +342,7 @@ export function getSelectedItem<T>(
|
||||
): T | undefined {
|
||||
return selection.current < 0
|
||||
? undefined
|
||||
: dataSource.getItem(selection.current);
|
||||
: dataSource.view.get(selection.current);
|
||||
}
|
||||
|
||||
export function getSelectedItems<T>(
|
||||
@@ -351,7 +351,7 @@ export function getSelectedItems<T>(
|
||||
): T[] {
|
||||
return [...selection.items]
|
||||
.sort()
|
||||
.map((i) => dataSource.getItem(i))
|
||||
.map((i) => dataSource.view.get(i))
|
||||
.filter(Boolean) as any[];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user