tinybase 8.2.0-beta.2 → 8.2.0

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/ui-react/index.js CHANGED
@@ -384,16 +384,19 @@ const addAndDelListener = (thing, listenable, ...args) => {
384
384
  return () => thing?.delListener?.(listenerId);
385
385
  };
386
386
  const useListenable = (listenable, thing, returnType, args = EMPTY_ARRAY) => {
387
- const lastResult = useRef(DEFAULTS[returnType]);
387
+ const lastResultRef = useRef(DEFAULTS[returnType]);
388
388
  const getResult = useCallback(
389
389
  () => {
390
390
  const nextResult =
391
391
  thing?.[(returnType == 6 /* Boolean */ ? _HAS : GET) + listenable]?.(
392
392
  ...args,
393
393
  ) ?? DEFAULTS[returnType];
394
- return !(IS_EQUALS[returnType] ?? isEqual)(nextResult, lastResult.current)
395
- ? (lastResult.current = nextResult)
396
- : lastResult.current;
394
+ return !(IS_EQUALS[returnType] ?? isEqual)(
395
+ nextResult,
396
+ lastResultRef.current,
397
+ )
398
+ ? (lastResultRef.current = nextResult)
399
+ : lastResultRef.current;
397
400
  },
398
401
  /* eslint-disable-next-line react-hooks/exhaustive-deps */
399
402
  [thing, returnType, listenable, ...args],
@@ -384,16 +384,19 @@ const addAndDelListener = (thing, listenable, ...args) => {
384
384
  return () => thing?.delListener?.(listenerId);
385
385
  };
386
386
  const useListenable = (listenable, thing, returnType, args = EMPTY_ARRAY) => {
387
- const lastResult = useRef(DEFAULTS[returnType]);
387
+ const lastResultRef = useRef(DEFAULTS[returnType]);
388
388
  const getResult = useCallback(
389
389
  () => {
390
390
  const nextResult =
391
391
  thing?.[(returnType == 6 /* Boolean */ ? _HAS : GET) + listenable]?.(
392
392
  ...args,
393
393
  ) ?? DEFAULTS[returnType];
394
- return !(IS_EQUALS[returnType] ?? isEqual)(nextResult, lastResult.current)
395
- ? (lastResult.current = nextResult)
396
- : lastResult.current;
394
+ return !(IS_EQUALS[returnType] ?? isEqual)(
395
+ nextResult,
396
+ lastResultRef.current,
397
+ )
398
+ ? (lastResultRef.current = nextResult)
399
+ : lastResultRef.current;
397
400
  },
398
401
  /* eslint-disable-next-line react-hooks/exhaustive-deps */
399
402
  [thing, returnType, listenable, ...args],
@@ -214,16 +214,19 @@ const addAndDelListener = (thing, listenable, ...args) => {
214
214
  return () => thing?.delListener?.(listenerId);
215
215
  };
216
216
  const useListenable = (listenable, thing, returnType, args = EMPTY_ARRAY) => {
217
- const lastResult = useRef(DEFAULTS[returnType]);
217
+ const lastResultRef = useRef(DEFAULTS[returnType]);
218
218
  const getResult = useCallback(
219
219
  () => {
220
220
  const nextResult =
221
221
  thing?.[(returnType == 6 /* Boolean */ ? _HAS : GET) + listenable]?.(
222
222
  ...args,
223
223
  ) ?? DEFAULTS[returnType];
224
- return !(IS_EQUALS[returnType] ?? isEqual)(nextResult, lastResult.current)
225
- ? (lastResult.current = nextResult)
226
- : lastResult.current;
224
+ return !(IS_EQUALS[returnType] ?? isEqual)(
225
+ nextResult,
226
+ lastResultRef.current,
227
+ )
228
+ ? (lastResultRef.current = nextResult)
229
+ : lastResultRef.current;
227
230
  },
228
231
  /* eslint-disable-next-line react-hooks/exhaustive-deps */
229
232
  [thing, returnType, listenable, ...args],
@@ -214,16 +214,19 @@ const addAndDelListener = (thing, listenable, ...args) => {
214
214
  return () => thing?.delListener?.(listenerId);
215
215
  };
216
216
  const useListenable = (listenable, thing, returnType, args = EMPTY_ARRAY) => {
217
- const lastResult = useRef(DEFAULTS[returnType]);
217
+ const lastResultRef = useRef(DEFAULTS[returnType]);
218
218
  const getResult = useCallback(
219
219
  () => {
220
220
  const nextResult =
221
221
  thing?.[(returnType == 6 /* Boolean */ ? _HAS : GET) + listenable]?.(
222
222
  ...args,
223
223
  ) ?? DEFAULTS[returnType];
224
- return !(IS_EQUALS[returnType] ?? isEqual)(nextResult, lastResult.current)
225
- ? (lastResult.current = nextResult)
226
- : lastResult.current;
224
+ return !(IS_EQUALS[returnType] ?? isEqual)(
225
+ nextResult,
226
+ lastResultRef.current,
227
+ )
228
+ ? (lastResultRef.current = nextResult)
229
+ : lastResultRef.current;
227
230
  },
228
231
  /* eslint-disable-next-line react-hooks/exhaustive-deps */
229
232
  [thing, returnType, listenable, ...args],
@@ -3006,16 +3006,19 @@ const addAndDelListener = (thing, listenable, ...args) => {
3006
3006
  return () => thing?.delListener?.(listenerId);
3007
3007
  };
3008
3008
  const useListenable = (listenable, thing, returnType, args = EMPTY_ARRAY) => {
3009
- const lastResult = useRef(DEFAULTS[returnType]);
3009
+ const lastResultRef = useRef(DEFAULTS[returnType]);
3010
3010
  const getResult = useCallback(
3011
3011
  () => {
3012
3012
  const nextResult =
3013
3013
  thing?.[(returnType == 6 /* Boolean */ ? _HAS : GET) + listenable]?.(
3014
3014
  ...args,
3015
3015
  ) ?? DEFAULTS[returnType];
3016
- return !(IS_EQUALS[returnType] ?? isEqual)(nextResult, lastResult.current)
3017
- ? (lastResult.current = nextResult)
3018
- : lastResult.current;
3016
+ return !(IS_EQUALS[returnType] ?? isEqual)(
3017
+ nextResult,
3018
+ lastResultRef.current,
3019
+ )
3020
+ ? (lastResultRef.current = nextResult)
3021
+ : lastResultRef.current;
3019
3022
  },
3020
3023
  /* eslint-disable-next-line react-hooks/exhaustive-deps */
3021
3024
  [thing, returnType, listenable, ...args],
@@ -3006,16 +3006,19 @@ const addAndDelListener = (thing, listenable, ...args) => {
3006
3006
  return () => thing?.delListener?.(listenerId);
3007
3007
  };
3008
3008
  const useListenable = (listenable, thing, returnType, args = EMPTY_ARRAY) => {
3009
- const lastResult = useRef(DEFAULTS[returnType]);
3009
+ const lastResultRef = useRef(DEFAULTS[returnType]);
3010
3010
  const getResult = useCallback(
3011
3011
  () => {
3012
3012
  const nextResult =
3013
3013
  thing?.[(returnType == 6 /* Boolean */ ? _HAS : GET) + listenable]?.(
3014
3014
  ...args,
3015
3015
  ) ?? DEFAULTS[returnType];
3016
- return !(IS_EQUALS[returnType] ?? isEqual)(nextResult, lastResult.current)
3017
- ? (lastResult.current = nextResult)
3018
- : lastResult.current;
3016
+ return !(IS_EQUALS[returnType] ?? isEqual)(
3017
+ nextResult,
3018
+ lastResultRef.current,
3019
+ )
3020
+ ? (lastResultRef.current = nextResult)
3021
+ : lastResultRef.current;
3019
3022
  },
3020
3023
  /* eslint-disable-next-line react-hooks/exhaustive-deps */
3021
3024
  [thing, returnType, listenable, ...args],