Functions
-
getEnhancedDataProvider<K, D>(dataProvider, capabilityConfigurations) : {DataProvider.<K, D>}
-
Utility function that enhances a base DataProvier with additional capabilities by wrapping it in other DataProviders.
Parameters:
Name Type Description dataProvider
DataProvider.<K, D> The base DataProvider to enhance. If this is a TreeDataProvider, the base DataProvider and each DataProvider returned by getChildDataProvider will be enhanced.
capabilityConfigurations
CapabilityConfigurations Capabilities being requested. The capabilities of the base DataProvider will be checked to see if it already supports at least the requested capabilities. Any capability it doesn't support will be provided by wrapping DataProviders. For example, if "visitedByCurrentIterator" caching is requested for the fetchFirst capability, and the base DataProvider already supports "all" or "visitedByCurrentIterator" caching, there is no need to wrap it. But if "forceLocalCaching" is set to "enabled" then wrapped dataprovider is returned irrespective of base dataprovider's caching capability.
Returns:
The outermost wrapping DataProvider. This may be the base DataProvider itself if it already supports all of the requested capabilities.
- Type
- DataProvider.<K, D>
Type Definitions
-
CapabilityConfigurations
-
Properties:
Name Type Argument Description eventFiltering
{type?: "iterator"} <optional>
If "iterator" is specified for the "type" property, enhance the base DataProvider to filter mutate events to hide items that are not within range of items that have been returned by its iterators. fetchByOffset
{caching?: "visitedByOffset"} <optional>
If "visitedByOffset" is specified for the "caching" property, enhance the base DataProvider to cache the results returned by fetchByOffset calls. Cached results, if available, can be returned when fetchByKeys, fetchByOffset, or containsKeys is called on the enhanced DataProvider. If fetchFirst caching and fetchByOffset caching both are specified then fetchByOffset caching wins over fetchFirst.
Note: In some scenarios, few cached records are refetched to avoid multiple fetch calls to underlying dataprovider. For example, row0 to row9 and row20 to row25 is cached. Now fetch request with offset 10 and size 20 will cause row20 to row25 to be refetched.fetchFirst
{caching?: "visitedByCurrentIterator", forceLocalCaching?: "enabled", totalFilteredRowCount?: "exact"} <optional>
If "visitedByCurrentIterator" is specified for the "caching" property and base dataprovider does not support caching, then enhance the base DataProvider to cache the results returned by its iterators. Cached results, if available, can be returned when fetchByKeys, fetchByOffset, or containsKeys is called on the enhanced DataProvider. If fetchFirst caching and fetchByOffset caching both are specified then fetchByOffset caching wins over fetchFirst. If "forceLocalCaching" is set to "enabled" then wrapped dataprovider is returned irrespective of base dataprovider's caching capability.
If "exact" is specified for the "totalFilteredRowCount" property, enhance the base DataProvider to include totalFilteredRowCount in the iterator results. Note that this enhancement can be expensive because all rows will be iterated to determine totalFilteredRowCount.
Examples
Using getEnhancedDataProvider() to retrieve a wrapper DataProvider with mutate event filtering capability
const enhancedDataProvider = getEnhancedDataProvider(baseDataProvider, { eventFiltering: {type: "iterator"}, } );
Using getEnhancedDataProvider() to retrieve a wrapper DataProvider with caching capability
const enhancedDataProvider = getEnhancedDataProvider(baseDataProvider, { fetchFirst: {caching: "visitedByCurrentIterator"} } );
Using getEnhancedDataProvider() to retrieve a wrapper DataProvider with all capabilities
const enhancedDataProvider = getEnhancedDataProvider(baseDataProvider, { eventFiltering: {type: "iterator"}, fetchFirst: {caching: "visitedByCurrentIterator"} } );