tsdf 11.1.5 → 11.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/dist/main.cjs CHANGED
@@ -250,7 +250,20 @@ function createFetchOrquestrator({
250
250
  }
251
251
  return lastFetchWasAborted;
252
252
  }
253
+ function reset() {
254
+ fetchs.a = null;
255
+ fetchs.c = null;
256
+ fetchs.b = null;
257
+ lastFetchStartTime = 0;
258
+ lastFetchDuration = 0;
259
+ lastFetchIdStarted = 0;
260
+ lastMutationIdStarted = 0;
261
+ mutationIsInProgress = false;
262
+ lastFetchWasAborted = false;
263
+ abortFetchsBeforeOrEqual = 0;
264
+ }
253
265
  return {
266
+ reset,
254
267
  scheduleFetch,
255
268
  awaitFetch,
256
269
  startMutation,
@@ -549,8 +562,18 @@ function newTSDFDocumentStore({
549
562
  );
550
563
  return true;
551
564
  }
565
+ function reset() {
566
+ fetchOrquestrator.reset();
567
+ store.setState({
568
+ data: null,
569
+ error: null,
570
+ status: "idle",
571
+ refetchOnMount: "lowPriority"
572
+ });
573
+ }
552
574
  return {
553
575
  store,
576
+ reset,
554
577
  awaitFetch,
555
578
  scheduleFetch,
556
579
  invalidateData,
@@ -576,8 +599,12 @@ function createCollectionFetchOrquestrator(props) {
576
599
  }
577
600
  return fetchOrquestrators.get(key);
578
601
  }
602
+ function reset() {
603
+ fetchOrquestrators.clear();
604
+ }
579
605
  return {
580
- get: getFetchOrquestrator
606
+ get: getFetchOrquestrator,
607
+ reset
581
608
  };
582
609
  }
583
610
 
@@ -1004,12 +1031,17 @@ function newTSDFCollectionStore({
1004
1031
  );
1005
1032
  return someItemWasUpdated;
1006
1033
  }
1034
+ function reset() {
1035
+ fetchOrquestrator.reset();
1036
+ store.setState({});
1037
+ }
1007
1038
  return {
1008
1039
  store,
1009
1040
  scheduleFetch,
1010
1041
  awaitFetch,
1011
1042
  useMultipleItems,
1012
1043
  useItem,
1044
+ reset,
1013
1045
  getItemKey,
1014
1046
  getItemState,
1015
1047
  startMutation,
@@ -1949,8 +1981,18 @@ function newTSDFListQueryStore({
1949
1981
  { action: { type: "delete-item-state", itemId } }
1950
1982
  );
1951
1983
  }
1984
+ function reset() {
1985
+ fetchItemOrquestrator?.reset();
1986
+ fetchQueryOrquestrator.reset();
1987
+ store.setState({
1988
+ items: {},
1989
+ queries: {},
1990
+ itemQueries: {}
1991
+ });
1992
+ }
1952
1993
  return {
1953
1994
  store,
1995
+ reset,
1954
1996
  scheduleListQueryFetch,
1955
1997
  getQueryState,
1956
1998
  getQueryKey,
package/dist/main.d.ts CHANGED
@@ -32,6 +32,7 @@ declare function newTSDFDocumentStore<State extends ValidStoreState, NError>({ d
32
32
  dynamicRealtimeThrottleMs?: (lastFetchDuration: number) => number;
33
33
  }): {
34
34
  store: Store<TSDFDocumentStoreState<State, NError>>;
35
+ reset: () => void;
35
36
  awaitFetch: () => Promise<{
36
37
  data: State;
37
38
  error: null;
@@ -115,6 +116,7 @@ declare function newTSDFCollectionStore<ItemState extends ValidStoreState, NErro
115
116
  ensureIsLoaded?: boolean | undefined;
116
117
  returnIdleStatus?: boolean | undefined;
117
118
  }) => TSFDUseCollectionItemReturn<Selected_1, ItemPayload, NError>;
119
+ reset: () => void;
118
120
  getItemKey: (params: ItemPayload) => string;
119
121
  getItemState: {
120
122
  (fetchParam: ItemPayload): TSFDCollectionItem<ItemState, ItemPayload, NError> | null | undefined;
@@ -204,6 +206,7 @@ declare function newTSDFListQueryStore<ItemState extends ValidStoreState, NError
204
206
  dynamicRealtimeThrottleMs?: (lastFetchDuration: number) => number;
205
207
  }): {
206
208
  store: Store<TSFDListQueryState<ItemState, NError, QueryPayload, ItemPayload>>;
209
+ reset: () => void;
207
210
  scheduleListQueryFetch: {
208
211
  (fetchType: FetchType, payload: QueryPayload, size?: number): ScheduleFetchResults;
209
212
  (fetchType: FetchType, payload: QueryPayload[], size?: number): ScheduleFetchResults[];
package/dist/main.js CHANGED
@@ -222,7 +222,20 @@ function createFetchOrquestrator({
222
222
  }
223
223
  return lastFetchWasAborted;
224
224
  }
225
+ function reset() {
226
+ fetchs.a = null;
227
+ fetchs.c = null;
228
+ fetchs.b = null;
229
+ lastFetchStartTime = 0;
230
+ lastFetchDuration = 0;
231
+ lastFetchIdStarted = 0;
232
+ lastMutationIdStarted = 0;
233
+ mutationIsInProgress = false;
234
+ lastFetchWasAborted = false;
235
+ abortFetchsBeforeOrEqual = 0;
236
+ }
225
237
  return {
238
+ reset,
226
239
  scheduleFetch,
227
240
  awaitFetch,
228
241
  startMutation,
@@ -521,8 +534,18 @@ function newTSDFDocumentStore({
521
534
  );
522
535
  return true;
523
536
  }
537
+ function reset() {
538
+ fetchOrquestrator.reset();
539
+ store.setState({
540
+ data: null,
541
+ error: null,
542
+ status: "idle",
543
+ refetchOnMount: "lowPriority"
544
+ });
545
+ }
524
546
  return {
525
547
  store,
548
+ reset,
526
549
  awaitFetch,
527
550
  scheduleFetch,
528
551
  invalidateData,
@@ -548,8 +571,12 @@ function createCollectionFetchOrquestrator(props) {
548
571
  }
549
572
  return fetchOrquestrators.get(key);
550
573
  }
574
+ function reset() {
575
+ fetchOrquestrators.clear();
576
+ }
551
577
  return {
552
- get: getFetchOrquestrator
578
+ get: getFetchOrquestrator,
579
+ reset
553
580
  };
554
581
  }
555
582
 
@@ -976,12 +1003,17 @@ function newTSDFCollectionStore({
976
1003
  );
977
1004
  return someItemWasUpdated;
978
1005
  }
1006
+ function reset() {
1007
+ fetchOrquestrator.reset();
1008
+ store.setState({});
1009
+ }
979
1010
  return {
980
1011
  store,
981
1012
  scheduleFetch,
982
1013
  awaitFetch,
983
1014
  useMultipleItems,
984
1015
  useItem,
1016
+ reset,
985
1017
  getItemKey,
986
1018
  getItemState,
987
1019
  startMutation,
@@ -1921,8 +1953,18 @@ function newTSDFListQueryStore({
1921
1953
  { action: { type: "delete-item-state", itemId } }
1922
1954
  );
1923
1955
  }
1956
+ function reset() {
1957
+ fetchItemOrquestrator?.reset();
1958
+ fetchQueryOrquestrator.reset();
1959
+ store.setState({
1960
+ items: {},
1961
+ queries: {},
1962
+ itemQueries: {}
1963
+ });
1964
+ }
1924
1965
  return {
1925
1966
  store,
1967
+ reset,
1926
1968
  scheduleListQueryFetch,
1927
1969
  getQueryState,
1928
1970
  getQueryKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsdf",
3
- "version": "11.1.5",
3
+ "version": "11.2.0",
4
4
  "description": "A data fetching solution based on t-state",
5
5
  "license": "MIT",
6
6
  "author": "Lucas Santos",