@livequery/react 1.0.99 → 1.0.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,5 @@
1
1
  import { LivequeryBaseEntity, QueryOption } from "@livequery/types";
2
2
  import { CollectionObservable, CollectionOption, CollectionStream } from "@livequery/client";
3
- import { Subject } from 'rxjs';
4
3
  export type useCollectionDataOptions<T extends LivequeryBaseEntity = LivequeryBaseEntity> = CollectionOption<T> & {
5
4
  lazy?: boolean;
6
5
  filters: Partial<QueryOption<T>>;
@@ -10,19 +9,4 @@ export type CollectionData<T extends LivequeryBaseEntity> = (CollectionStream<T>
10
9
  empty: boolean;
11
10
  });
12
11
  export type CollectionRef = string | undefined | '' | null | false;
13
- export declare const useCollectionData: <T extends LivequeryBaseEntity>(ref: CollectionRef, collection_options?: Partial<useCollectionDataOptions<T>>) => CollectionData<T> | {
14
- error: undefined;
15
- $changes: Subject<unknown>;
16
- add: () => void;
17
- empty: boolean;
18
- filter: () => void;
19
- fetch_more: () => void;
20
- filters: {};
21
- has_more: boolean;
22
- items: never[];
23
- reload: () => void;
24
- reset: () => void;
25
- trigger: () => void;
26
- update: () => void;
27
- loading: boolean;
28
- };
12
+ export declare const useCollectionData: <T extends LivequeryBaseEntity>(ref: CollectionRef, collection_options?: Partial<useCollectionDataOptions<T>>) => CollectionData<T>;
@@ -7,24 +7,6 @@ function assert(fn, thiss) {
7
7
  return (fn || (() => { })).bind(thiss);
8
8
  }
9
9
  export const useCollectionData = (ref, collection_options = {}) => {
10
- if (typeof window == 'undefined' || !ref) {
11
- return {
12
- error: undefined,
13
- $changes: new Subject(),
14
- add: (() => { }),
15
- empty: false,
16
- filter: (() => { }),
17
- fetch_more: (() => { }),
18
- filters: {},
19
- has_more: false,
20
- items: [],
21
- reload: (() => { }),
22
- reset: (() => { }),
23
- trigger: (() => { }),
24
- update: (() => { }),
25
- loading: false
26
- };
27
- }
28
10
  const { transporter } = useLiveQueryContext();
29
11
  const [stream, ss] = useState({
30
12
  filters: {},
@@ -35,6 +17,8 @@ export const useCollectionData = (ref, collection_options = {}) => {
35
17
  });
36
18
  const collection_ref = useRef();
37
19
  useEffect(() => {
20
+ if (!ref || typeof window == 'undefined')
21
+ return;
38
22
  const collection = collection_ref.current = new CollectionObservable(ref, { transporter, ...collection_options });
39
23
  const subscription = collection.subscribe(data => {
40
24
  collection_options.load_all && data.loading == false && data.has_more && collection?.fetch_more();
@@ -9,6 +9,6 @@ export declare const useDocumentData: <T extends {
9
9
  item: import("@livequery/client").SmartQueryItem<T>;
10
10
  loading: boolean | undefined;
11
11
  error: import("@livequery/types").ErrorInfo | undefined;
12
- reload: (() => void) | (() => void);
13
- $changes: import("rxjs").Subject<unknown> | import("rxjs").Subject<import("@livequery/types").UpdatedData<T>>;
12
+ reload: () => void;
13
+ $changes: import("rxjs").Subject<import("@livequery/types").UpdatedData<T>>;
14
14
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "url": "https://github.com/livequery/react"
5
5
  },
6
6
  "type": "module",
7
- "version": "1.0.99",
7
+ "version": "1.0.100",
8
8
  "description": "",
9
9
  "main": "build/index.js",
10
10
  "types": "build/index.d.ts",