@tanstack/react-db
Version:
React integration for @tanstack/db
18 lines (17 loc) • 833 B
JavaScript
import { getPreparedLiveQuerySources } from "@tanstack/db";
// src/source-id-bindings.ts
/**
* Reports a descriptor source that no DbClient bound, naming the provider a
* React tree needs. Returns `undefined` when a client can bind descriptors.
*/
function getUnboundDescriptorReporter(client, hookName) {
if (client) return void 0;
return (alias) => {
throw new Error(`[${hookName}] Collection descriptor "${alias}" requires a DbClient when the query is consumed. Wrap this component in <DbProvider client={client}> or use a concrete Collection.`);
};
}
function getPreparedSources(preparedValue, client, hookName) {
return getPreparedLiveQuerySources(preparedValue, getUnboundDescriptorReporter(client, hookName));
}
export { getPreparedSources, getUnboundDescriptorReporter };
//# sourceMappingURL=source-id-bindings.js.map