live-cache 0.2.4 → 0.2.5
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.cjs +8 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +8 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/react/useController.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1457,7 +1457,7 @@ function useRegister(controller, store = getDefaultObjectStore()) {
|
|
|
1457
1457
|
* );
|
|
1458
1458
|
* ```
|
|
1459
1459
|
*/
|
|
1460
|
-
function useController(
|
|
1460
|
+
function useController(controllerInstance, where, options) {
|
|
1461
1461
|
var _a, _b;
|
|
1462
1462
|
const optionalStore = options === null || options === void 0 ? void 0 : options.store;
|
|
1463
1463
|
const withInvalidation = (_a = options === null || options === void 0 ? void 0 : options.withInvalidation) !== null && _a !== void 0 ? _a : true;
|
|
@@ -1469,7 +1469,12 @@ function useController(name, where, options) {
|
|
|
1469
1469
|
if (!store) {
|
|
1470
1470
|
throw Error("Store is not defined");
|
|
1471
1471
|
}
|
|
1472
|
-
const controller = useMemo(() =>
|
|
1472
|
+
const controller = useMemo(() => {
|
|
1473
|
+
if (!store.get(controllerInstance.name)) {
|
|
1474
|
+
store.register(controllerInstance);
|
|
1475
|
+
}
|
|
1476
|
+
return store.get(controllerInstance.name);
|
|
1477
|
+
}, [controllerInstance, store]);
|
|
1473
1478
|
useEffect(() => {
|
|
1474
1479
|
const callback = () => {
|
|
1475
1480
|
var _a;
|
|
@@ -1483,7 +1488,7 @@ function useController(name, where, options) {
|
|
|
1483
1488
|
if (withInvalidation) {
|
|
1484
1489
|
controller.invalidator.registerInvalidation();
|
|
1485
1490
|
}
|
|
1486
|
-
void store.initialiseOnce(name, where);
|
|
1491
|
+
void store.initialiseOnce(controller.name, where);
|
|
1487
1492
|
return () => {
|
|
1488
1493
|
controller.abort();
|
|
1489
1494
|
cleanup();
|