shelving 1.65.0 → 1.65.1

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.
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.65.0",
14
+ "version": "1.65.1",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -16,7 +16,7 @@ export class DocumentState extends State {
16
16
  this._table = findSourceProvider(ref.db.provider, CacheProvider).memory.getTable(ref);
17
17
  this.ref = ref;
18
18
  // If the result is cached use it as the initial value.
19
- const isCached = this._table.getDocumentTime(ref.id) !== undefined;
19
+ const isCached = typeof this._table.getDocumentTime(ref.id) === "number";
20
20
  if (isCached)
21
21
  this.next(this._table.getDocument(ref.id)); // Use the existing cached value.
22
22
  else
package/react/useQuery.js CHANGED
@@ -56,7 +56,7 @@ export class QueryState extends State {
56
56
  this.ref = ref;
57
57
  this.limit = (_a = ref.limit) !== null && _a !== void 0 ? _a : Infinity;
58
58
  // If the result is cached use it as the initial value.
59
- const isCached = this._table.getQueryTime(ref) !== undefined;
59
+ const isCached = typeof this._table.getQueryTime(ref) === "number";
60
60
  if (isCached)
61
61
  this.next(this._table.getQuery(ref)); // Use the existing cached value.
62
62
  else
@@ -117,7 +117,5 @@ const _getQueryState = (previous, ref) => !ref ? undefined : previous && isSameR
117
117
  export function useQuery(ref) {
118
118
  const state = useReduce(_getQueryState, ref);
119
119
  useSubscribe(state);
120
- if (state && !state.exists)
121
- dispatch(state.refresh); // Load the query if it isn't cached already.
122
120
  return state;
123
121
  }
@@ -11,6 +11,6 @@ import { BLACKHOLE } from "../util/function.js";
11
11
  * - Memoise this value to persist the subscription for the lifetime of the component.
12
12
  */
13
13
  export function useSubscribe(subscribable) {
14
- const setState = useState(subscribable instanceof State && subscribable.exists ? subscribable.value : NOVALUE)[1];
14
+ const setState = useState(subscribable instanceof State && !subscribable.loading ? subscribable.value : NOVALUE)[1];
15
15
  useEffect(subscribable ? () => subscribe(subscribable, { next: setState, error: setState }) : BLACKHOLE, [subscribable]);
16
16
  }
@@ -28,7 +28,7 @@ export class OptionalDataState extends State {
28
28
  get data() {
29
29
  if (this.reason !== NOERROR)
30
30
  throw this.reason;
31
- if (!this.exists)
31
+ if (this.loading)
32
32
  throw awaitNext(this).then(getData);
33
33
  return getData(this.value);
34
34
  }
package/state/State.d.ts CHANGED
@@ -23,7 +23,7 @@ export declare class State<T> extends Subject<T> implements Matchable<T, void> {
23
23
  /** State is initiated with an initial state. */
24
24
  constructor(...args: [] | [T]);
25
25
  /** Is there a current value, or is it still loading. */
26
- get exists(): boolean;
26
+ get loading(): boolean;
27
27
  next(value: T): void;
28
28
  error(reason: Error | unknown): void;
29
29
  protected _addObserver(observer: Observer<T>): void;
package/state/State.js CHANGED
@@ -30,8 +30,8 @@ export class State extends Subject {
30
30
  return this._value;
31
31
  }
32
32
  /** Is there a current value, or is it still loading. */
33
- get exists() {
34
- return this._value !== NOVALUE;
33
+ get loading() {
34
+ return this._value === NOVALUE;
35
35
  }
36
36
  // Override to only dispatch if the value changes.
37
37
  next(value) {