tsdf 8.0.0-beta.17 → 8.0.0-beta.19
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/main.cjs +14 -6
- package/dist/main.d.ts +3 -1
- package/dist/main.js +14 -6
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -1635,12 +1635,13 @@ function newTSDFListQueryStore({
|
|
|
1635
1635
|
}
|
|
1636
1636
|
}
|
|
1637
1637
|
function startItemMutation(itemId) {
|
|
1638
|
-
if (!fetchItemOrquestrator)
|
|
1639
|
-
throw new Error(noFetchFnError);
|
|
1640
1638
|
const itemsKey = getItemsKeyArray(itemId);
|
|
1641
1639
|
const endMutations = [];
|
|
1642
1640
|
for (const { itemKey, payload } of itemsKey) {
|
|
1643
|
-
endMutations.push(
|
|
1641
|
+
endMutations.push(
|
|
1642
|
+
fetchItemOrquestrator?.get(itemKey).startMutation() || (() => {
|
|
1643
|
+
})
|
|
1644
|
+
);
|
|
1644
1645
|
if (syncMutationsAndInvalidations) {
|
|
1645
1646
|
for (const [queryKey, query] of Object.entries(store.state.queries)) {
|
|
1646
1647
|
if (syncMutationsAndInvalidations.syncItemAndQuery(
|
|
@@ -1667,7 +1668,8 @@ function newTSDFListQueryStore({
|
|
|
1667
1668
|
selector = defaultItemDataSelector,
|
|
1668
1669
|
returnIdleStatus,
|
|
1669
1670
|
returnRefetchingStatus,
|
|
1670
|
-
disableRefetchOnMount
|
|
1671
|
+
disableRefetchOnMount,
|
|
1672
|
+
loadFromStateOnly
|
|
1671
1673
|
} = {}) {
|
|
1672
1674
|
const dataSelector = (0, import_react5.useCallback)(selector, []);
|
|
1673
1675
|
const memoizedItemKeys = useDeepMemo(
|
|
@@ -1732,6 +1734,8 @@ function newTSDFListQueryStore({
|
|
|
1732
1734
|
useExternalDeps: true
|
|
1733
1735
|
});
|
|
1734
1736
|
useOnMittEvent(storeEvents, "invalidateItem", (event) => {
|
|
1737
|
+
if (loadFromStateOnly)
|
|
1738
|
+
return;
|
|
1735
1739
|
for (const { payload, itemKey } of memoizedItemKeys) {
|
|
1736
1740
|
if (itemKey !== event.itemKey)
|
|
1737
1741
|
continue;
|
|
@@ -1742,6 +1746,8 @@ function newTSDFListQueryStore({
|
|
|
1742
1746
|
}
|
|
1743
1747
|
});
|
|
1744
1748
|
(0, import_react5.useEffect)(() => {
|
|
1749
|
+
if (loadFromStateOnly)
|
|
1750
|
+
return;
|
|
1745
1751
|
for (const { payload, itemKey } of memoizedItemKeys) {
|
|
1746
1752
|
if (itemKey) {
|
|
1747
1753
|
const itemState = store.state.itemQueries[itemKey];
|
|
@@ -1757,7 +1763,7 @@ function newTSDFListQueryStore({
|
|
|
1757
1763
|
}
|
|
1758
1764
|
}
|
|
1759
1765
|
}
|
|
1760
|
-
}, [disableRefetchOnMount, memoizedItemKeys]);
|
|
1766
|
+
}, [disableRefetchOnMount, loadFromStateOnly, memoizedItemKeys]);
|
|
1761
1767
|
return storeState;
|
|
1762
1768
|
}
|
|
1763
1769
|
function useItem(itemPayload, options = {}) {
|
|
@@ -1889,7 +1895,9 @@ function newTSDFListQueryStore({
|
|
|
1889
1895
|
if (!disableRefetchOnWindowFocus) {
|
|
1890
1896
|
let handleFocus2 = function() {
|
|
1891
1897
|
invalidateQuery(() => true, "lowPriority");
|
|
1892
|
-
|
|
1898
|
+
if (fetchItemFn) {
|
|
1899
|
+
invalidateItem(() => true, "lowPriority");
|
|
1900
|
+
}
|
|
1893
1901
|
};
|
|
1894
1902
|
var handleFocus = handleFocus2;
|
|
1895
1903
|
window.addEventListener("focus", handleFocus2);
|
package/dist/main.d.ts
CHANGED
|
@@ -275,12 +275,14 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
|
|
|
275
275
|
returnIdleStatus?: boolean | undefined;
|
|
276
276
|
returnRefetchingStatus?: boolean | undefined;
|
|
277
277
|
ensureIsLoaded?: boolean | undefined;
|
|
278
|
+
loadFromStateOnly?: boolean | undefined;
|
|
278
279
|
}) => TSFDUseListItemReturn<SelectedItem_2, NError, ItemPayload>;
|
|
279
|
-
useMultipleItems: <SelectedItem_3 = ItemState | null>(itemsPayload_: ItemPayload[], { selector, returnIdleStatus, returnRefetchingStatus, disableRefetchOnMount, }?: {
|
|
280
|
+
useMultipleItems: <SelectedItem_3 = ItemState | null>(itemsPayload_: ItemPayload[], { selector, returnIdleStatus, returnRefetchingStatus, disableRefetchOnMount, loadFromStateOnly, }?: {
|
|
280
281
|
selector?: ((data: ItemState | null, id: string) => SelectedItem_3) | undefined;
|
|
281
282
|
disableRefetchOnMount?: boolean | undefined;
|
|
282
283
|
returnIdleStatus?: boolean | undefined;
|
|
283
284
|
returnRefetchingStatus?: boolean | undefined;
|
|
285
|
+
loadFromStateOnly?: boolean | undefined;
|
|
284
286
|
}) => readonly TSFDUseListItemReturn<SelectedItem_3, NError, ItemPayload>[];
|
|
285
287
|
addItemToState: (itemPayload: ItemPayload, data: ItemState, { addItemToQueries, }?: {
|
|
286
288
|
addItemToQueries?: {
|
package/dist/main.js
CHANGED
|
@@ -1601,12 +1601,13 @@ function newTSDFListQueryStore({
|
|
|
1601
1601
|
}
|
|
1602
1602
|
}
|
|
1603
1603
|
function startItemMutation(itemId) {
|
|
1604
|
-
if (!fetchItemOrquestrator)
|
|
1605
|
-
throw new Error(noFetchFnError);
|
|
1606
1604
|
const itemsKey = getItemsKeyArray(itemId);
|
|
1607
1605
|
const endMutations = [];
|
|
1608
1606
|
for (const { itemKey, payload } of itemsKey) {
|
|
1609
|
-
endMutations.push(
|
|
1607
|
+
endMutations.push(
|
|
1608
|
+
fetchItemOrquestrator?.get(itemKey).startMutation() || (() => {
|
|
1609
|
+
})
|
|
1610
|
+
);
|
|
1610
1611
|
if (syncMutationsAndInvalidations) {
|
|
1611
1612
|
for (const [queryKey, query] of Object.entries(store.state.queries)) {
|
|
1612
1613
|
if (syncMutationsAndInvalidations.syncItemAndQuery(
|
|
@@ -1633,7 +1634,8 @@ function newTSDFListQueryStore({
|
|
|
1633
1634
|
selector = defaultItemDataSelector,
|
|
1634
1635
|
returnIdleStatus,
|
|
1635
1636
|
returnRefetchingStatus,
|
|
1636
|
-
disableRefetchOnMount
|
|
1637
|
+
disableRefetchOnMount,
|
|
1638
|
+
loadFromStateOnly
|
|
1637
1639
|
} = {}) {
|
|
1638
1640
|
const dataSelector = useCallback3(selector, []);
|
|
1639
1641
|
const memoizedItemKeys = useDeepMemo(
|
|
@@ -1698,6 +1700,8 @@ function newTSDFListQueryStore({
|
|
|
1698
1700
|
useExternalDeps: true
|
|
1699
1701
|
});
|
|
1700
1702
|
useOnMittEvent(storeEvents, "invalidateItem", (event) => {
|
|
1703
|
+
if (loadFromStateOnly)
|
|
1704
|
+
return;
|
|
1701
1705
|
for (const { payload, itemKey } of memoizedItemKeys) {
|
|
1702
1706
|
if (itemKey !== event.itemKey)
|
|
1703
1707
|
continue;
|
|
@@ -1708,6 +1712,8 @@ function newTSDFListQueryStore({
|
|
|
1708
1712
|
}
|
|
1709
1713
|
});
|
|
1710
1714
|
useEffect4(() => {
|
|
1715
|
+
if (loadFromStateOnly)
|
|
1716
|
+
return;
|
|
1711
1717
|
for (const { payload, itemKey } of memoizedItemKeys) {
|
|
1712
1718
|
if (itemKey) {
|
|
1713
1719
|
const itemState = store.state.itemQueries[itemKey];
|
|
@@ -1723,7 +1729,7 @@ function newTSDFListQueryStore({
|
|
|
1723
1729
|
}
|
|
1724
1730
|
}
|
|
1725
1731
|
}
|
|
1726
|
-
}, [disableRefetchOnMount, memoizedItemKeys]);
|
|
1732
|
+
}, [disableRefetchOnMount, loadFromStateOnly, memoizedItemKeys]);
|
|
1727
1733
|
return storeState;
|
|
1728
1734
|
}
|
|
1729
1735
|
function useItem(itemPayload, options = {}) {
|
|
@@ -1855,7 +1861,9 @@ function newTSDFListQueryStore({
|
|
|
1855
1861
|
if (!disableRefetchOnWindowFocus) {
|
|
1856
1862
|
let handleFocus2 = function() {
|
|
1857
1863
|
invalidateQuery(() => true, "lowPriority");
|
|
1858
|
-
|
|
1864
|
+
if (fetchItemFn) {
|
|
1865
|
+
invalidateItem(() => true, "lowPriority");
|
|
1866
|
+
}
|
|
1859
1867
|
};
|
|
1860
1868
|
var handleFocus = handleFocus2;
|
|
1861
1869
|
window.addEventListener("focus", handleFocus2);
|