Skip to content

Commit

Permalink
feat: added usebook enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mbret committed May 21, 2024
1 parent ec32ac7 commit 71b8ad5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/web/src/books/states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,16 @@ export const useBooksDic = () => {
return { ...rest, data: data ? keyBy(data, "_id") : undefined }
}

export const useBook = ({ id }: { id?: string }) => {
export const useBook = ({
id,
enabled = true
}: {
id?: string
enabled?: boolean
}) => {
return useForeverQuery({
queryKey: ["rxdb", "book", id],
enabled: !!id,
queryKey: ["rxdb", "book", { id }],
enabled: enabled && !!id,
queryFn: () => {
return latestDatabase$.pipe(
switchMap(
Expand Down

0 comments on commit 71b8ad5

Please sign in to comment.