@basictech/react 0.2.0-beta.1 → 0.2.0-beta.2

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/dist/index.mjs CHANGED
@@ -8249,89 +8249,12 @@ function useBasic() {
8249
8249
  return useContext(BasicContext);
8250
8250
  }
8251
8251
 
8252
- // ../../node_modules/dexie-react-hooks/dist/dexie-react-hooks.mjs
8253
- import React2 from "react";
8254
- function useObservable(observableFactory, arg2, arg3) {
8255
- var deps;
8256
- var defaultResult;
8257
- if (typeof observableFactory === "function") {
8258
- deps = arg2 || [];
8259
- defaultResult = arg3;
8260
- } else {
8261
- deps = [];
8262
- defaultResult = arg2;
8263
- }
8264
- var monitor = React2.useRef({
8265
- hasResult: false,
8266
- result: defaultResult,
8267
- error: null
8268
- });
8269
- var _a = React2.useReducer(function(x) {
8270
- return x + 1;
8271
- }, 0);
8272
- _a[0];
8273
- var triggerUpdate = _a[1];
8274
- var observable = React2.useMemo(function() {
8275
- var observable2 = typeof observableFactory === "function" ? observableFactory() : observableFactory;
8276
- if (!observable2 || typeof observable2.subscribe !== "function") {
8277
- if (observableFactory === observable2) {
8278
- throw new TypeError("Given argument to useObservable() was neither a valid observable nor a function.");
8279
- } else {
8280
- throw new TypeError("Observable factory given to useObservable() did not return a valid observable.");
8281
- }
8282
- }
8283
- if (!monitor.current.hasResult && typeof window !== "undefined") {
8284
- if (typeof observable2.hasValue !== "function" || observable2.hasValue()) {
8285
- if (typeof observable2.getValue === "function") {
8286
- monitor.current.result = observable2.getValue();
8287
- monitor.current.hasResult = true;
8288
- } else {
8289
- var subscription = observable2.subscribe(function(val) {
8290
- monitor.current.result = val;
8291
- monitor.current.hasResult = true;
8292
- });
8293
- if (typeof subscription === "function") {
8294
- subscription();
8295
- } else {
8296
- subscription.unsubscribe();
8297
- }
8298
- }
8299
- }
8300
- }
8301
- return observable2;
8302
- }, deps);
8303
- React2.useDebugValue(monitor.current.result);
8304
- React2.useEffect(function() {
8305
- var subscription = observable.subscribe(function(val) {
8306
- var current = monitor.current;
8307
- if (current.error !== null || current.result !== val) {
8308
- current.error = null;
8309
- current.result = val;
8310
- current.hasResult = true;
8311
- triggerUpdate();
8312
- }
8313
- }, function(err) {
8314
- var current = monitor.current;
8315
- if (current.error !== err) {
8316
- current.error = err;
8317
- triggerUpdate();
8318
- }
8319
- });
8320
- return typeof subscription === "function" ? subscription : subscription.unsubscribe.bind(subscription);
8321
- }, deps);
8322
- if (monitor.current.error)
8323
- throw monitor.current.error;
8324
- return monitor.current.result;
8325
- }
8326
- function useLiveQuery(querier, deps, defaultResult) {
8327
- return useObservable(function() {
8328
- return liveQuery(querier);
8329
- }, deps || [], defaultResult);
8330
- }
8252
+ // src/index.ts
8253
+ import { useLiveQuery as useQuery } from "dexie-react-hooks";
8331
8254
  export {
8332
8255
  BasicProvider,
8333
8256
  useBasic,
8334
- useLiveQuery as useQuery
8257
+ useQuery
8335
8258
  };
8336
8259
  /*! Bundled license information:
8337
8260