Changed documentation with DataSource to be up to date
Summary: Since there were large refactoring's done to `DataSource` during the milestone for side-by-side panels, wanted to update some of the documentation as well so that the information is accurate and up to date. Reviewed By: mweststrate Differential Revision: D38541404 fbshipit-source-id: a6ba472f881fb8cbfa90ff5ac295a0b87c595080
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b7c38556ce
commit
02c21f5cb0
@@ -438,6 +438,13 @@ export class DataSource<T extends any, KeyType = never> {
|
|||||||
return newView;
|
return newView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new view of the `DataSource` if there doesn't exist a `DataSourceView` with the `viewId` passed in.
|
||||||
|
* The view will allow different filters and sortings on the `DataSource` which can be helpful in cases
|
||||||
|
* where multiple tables/views are needed.
|
||||||
|
* @param viewId id for the `DataSourceView`
|
||||||
|
* @returns `DataSourceView` that corresponds to the `viewId`
|
||||||
|
*/
|
||||||
public getAdditionalView(viewId: string): DataSourceView<T, KeyType> {
|
public getAdditionalView(viewId: string): DataSourceView<T, KeyType> {
|
||||||
if (viewId in this.additionalViews) {
|
if (viewId in this.additionalViews) {
|
||||||
return this.additionalViews[viewId];
|
return this.additionalViews[viewId];
|
||||||
|
|||||||
@@ -575,10 +575,11 @@ To optimise for this situation, there is a dedicated `createDataSource` abstract
|
|||||||
`DataSource` is a data collection that is heavily optimized for `append` and `update`,
|
`DataSource` is a data collection that is heavily optimized for `append` and `update`,
|
||||||
which stores items based on insertion order, but also allows for efficient by-id lookups.
|
which stores items based on insertion order, but also allows for efficient by-id lookups.
|
||||||
|
|
||||||
Each `DataSource` exposes a `view` property, which contains a `DataSourceView`.
|
Each `DataSource` exposes a default `view` property, which contains a `DataSourceView`.
|
||||||
A `DataSourceView` is a materialized view that can be sorted, filtered and windowed, and is kept incrementally up to date with the underlying `DataSource`.
|
A `DataSourceView` is a materialized view that can be sorted, filtered and windowed, and is kept incrementally up to date with the underlying `DataSource`.
|
||||||
|
|
||||||
When using the `DataTable` component, this `view` will be managed by the table automatically, giving plugin users the capability to freely sort, filter, search and tail your datasource.
|
When using the `DataTable` component, this `view` will be managed by the table automatically, giving plugin users the capability to freely sort, filter, search and tail your datasource.
|
||||||
|
Alternatively, you could also pass in a different view(like from additionalViews) to the `DataTable` component which allows for different filters, searches, etc. than the default `view`.
|
||||||
|
|
||||||
Valid `options` are:
|
Valid `options` are:
|
||||||
|
|
||||||
@@ -617,7 +618,11 @@ The maximum number of records that can be stored in this DataSource to constrain
|
|||||||
|
|
||||||
##### view
|
##### view
|
||||||
|
|
||||||
Returns the currently active view on the data source. Note that be default it is windowed on the impractical `[0, 0)` range. For more details, see [DataSourceView](#datasourceview).
|
Returns the currently active default view on the data source. Note that be default it is windowed on the impractical `[0, 0)` range. For more details, see [DataSourceView](#datasourceview).
|
||||||
|
|
||||||
|
##### additionalViews
|
||||||
|
|
||||||
|
Holds additional `DataSourceView` on this `DataSource`. It contains key of `viewId: string` and value of `DataSourceView<T, KeyType>`. The default view in `DataSource` has `DEFAULT_VIEW_ID = '0'`, so all additionalViews cannot use this as the `viewId`. This is a `readonly` array and additional views are appended to the array by calling `getAdditionalView(viewId: string)` with a new `viewId`
|
||||||
|
|
||||||
##### size
|
##### size
|
||||||
|
|
||||||
@@ -675,9 +680,9 @@ Usage: `shift(amount: number)`. Removes the first `amount` records from the data
|
|||||||
|
|
||||||
Usage: `clear()`. Removes all records from this data source.
|
Usage: `clear()`. Removes all records from this data source.
|
||||||
|
|
||||||
##### fork
|
##### getAdditionalView
|
||||||
|
|
||||||
Usage: `fork(): DataSourceView`. Creates an additional materialized view on this data source with its own sort / filter settings. This feature is not implemented yet so contact Flipper oncall if needed.
|
Usage: `getAdditionalView(viewId: string)`. Gets an additional `DataSourceView` of the `DataSource` by passing in an identifier `viewId`. If there already exists a `DataSourceView` with the `viewId`, we simply return that view instead.
|
||||||
|
|
||||||
#### DataSourceView
|
#### DataSourceView
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user