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.cjs
CHANGED
|
@@ -1461,7 +1461,7 @@ function useRegister(controller, store = getDefaultObjectStore()) {
|
|
|
1461
1461
|
* );
|
|
1462
1462
|
* ```
|
|
1463
1463
|
*/
|
|
1464
|
-
function useController(
|
|
1464
|
+
function useController(controllerInstance, where, options) {
|
|
1465
1465
|
var _a, _b;
|
|
1466
1466
|
const optionalStore = options === null || options === void 0 ? void 0 : options.store;
|
|
1467
1467
|
const withInvalidation = (_a = options === null || options === void 0 ? void 0 : options.withInvalidation) !== null && _a !== void 0 ? _a : true;
|
|
@@ -1473,7 +1473,12 @@ function useController(name, where, options) {
|
|
|
1473
1473
|
if (!store) {
|
|
1474
1474
|
throw Error("Store is not defined");
|
|
1475
1475
|
}
|
|
1476
|
-
const controller = React.useMemo(() =>
|
|
1476
|
+
const controller = React.useMemo(() => {
|
|
1477
|
+
if (!store.get(controllerInstance.name)) {
|
|
1478
|
+
store.register(controllerInstance);
|
|
1479
|
+
}
|
|
1480
|
+
return store.get(controllerInstance.name);
|
|
1481
|
+
}, [controllerInstance, store]);
|
|
1477
1482
|
React.useEffect(() => {
|
|
1478
1483
|
const callback = () => {
|
|
1479
1484
|
var _a;
|
|
@@ -1487,7 +1492,7 @@ function useController(name, where, options) {
|
|
|
1487
1492
|
if (withInvalidation) {
|
|
1488
1493
|
controller.invalidator.registerInvalidation();
|
|
1489
1494
|
}
|
|
1490
|
-
void store.initialiseOnce(name, where);
|
|
1495
|
+
void store.initialiseOnce(controller.name, where);
|
|
1491
1496
|
return () => {
|
|
1492
1497
|
controller.abort();
|
|
1493
1498
|
cleanup();
|