Skip to content

Commit

Permalink
useDeepId and debug useDeepQ/S
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Jun 26, 2023
1 parent e0dd2ce commit a4d5da7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions imports/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,7 @@ export function useDeepQuery<Table extends 'links'|'numbers'|'strings'|'objects'
loading: boolean;
} {
const [miniName] = useState(options?.mini || Math.random().toString(36).slice(2, 7));
debug('useDeepQuery', miniName, query, options);
const deep = useDeep();
const wq = useMemo(() => {
const sq = serializeQuery(query);
Expand Down Expand Up @@ -1125,6 +1126,7 @@ export function useDeepSubscription<Table extends 'links'|'numbers'|'strings'|'o
},
): UseDeepSubscriptionResult<LL> {
const [miniName] = useState(options?.mini || Math.random().toString(36).slice(2, 7));
debug('useDeepSubscription', miniName, query, options);
const deep = useDeep();
const wq = useMemo(() => {
const sq = serializeQuery(query);
Expand Down Expand Up @@ -1158,4 +1160,9 @@ export interface UseDeepSubscriptionResult<LL = Link<number>> {
data?: LL[];
error?: any;
loading: boolean;
}

export function useDeepId(start: DeepClientStartItem | QueryLink, ...path: DeepClientPathItem[]): { data: number; loading: boolean; error?: any } {
const result = useDeepQuery({ id: { _id: [start, ...path] } });
return { data: result?.data?.[0]?.id, loading: result?.loading, error: result?.error };
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deep-foundation/deeplinks",
"version": "0.0.196",
"version": "0.0.197",
"license": "Unlicense",
"type": "module",
"scripts": {
Expand Down

0 comments on commit a4d5da7

Please sign in to comment.