@gravity-ui/data-source
Version:
A wrapper around data fetching
39 lines (38 loc) • 1.2 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.skipContext = void 0;
/**
* @description
*
* The function is intended to be used with the `fetch` parameter of the query data source config.
* It is used to ignore the query data context and the query function context parameters.
*
* NOTE: When passed directly to the `fetch` parameter, typescript fails to infer the types of the `DataSource` fields.
* It is better to define a constant first.
*
* @example
*
* function someFetchFunction(request: TRequest) {...}
*
* const fetchData = skipContext(someFetchFunction);
*
* const dataSource = makePlainQueryDataSource({
* ...
* fetch: fetchData,
* ...
* })
*
* @param fetch fetch function
* @returns fetch function with the ignored query data source context and the query function context.
*/
var skipContext = exports.skipContext = function skipContext(fetch) {
return function (_0, _1) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
return fetch.apply(void 0, args);
};
};
// #sourceMappingURL=skipContext.js.map
;