@spoosh/angular 0.4.0 → 0.6.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/README.md CHANGED
@@ -29,7 +29,7 @@ export const { injectRead, injectWrite, injectInfiniteRead } =
29
29
 
30
30
  ### injectRead
31
31
 
32
- Fetch data with automatic caching and refetching using Angular signals.
32
+ Fetch data with automatic caching and triggering using Angular signals.
33
33
 
34
34
  ```typescript
35
35
  @Component({
@@ -187,7 +187,7 @@ export class PostListComponent {
187
187
  | `loading` | `Signal<boolean>` | True during initial load |
188
188
  | `fetching` | `Signal<boolean>` | True during any fetch |
189
189
  | `meta` | `Signal<PluginResults>` | Plugin metadata (e.g., `transformedData`) |
190
- | `refetch` | `() => Promise` | Manually trigger refetch |
190
+ | `trigger` | `() => Promise` | Manually trigger fetch |
191
191
  | `abort` | `() => void` | Abort current request |
192
192
 
193
193
  ### injectWrite(writeFn)
@@ -202,7 +202,6 @@ export class PostListComponent {
202
202
  | `loading` | `Signal<boolean>` | True while mutation is in progress |
203
203
  | `meta` | `Signal<PluginResults>` | Plugin metadata |
204
204
  | `input` | `TriggerOptions \| undefined` | Last trigger input |
205
- | `reset` | `() => void` | Reset state |
206
205
  | `abort` | `() => void` | Abort current request |
207
206
 
208
207
  ### injectInfiniteRead(readFn, options)
package/dist/index.d.mts CHANGED
@@ -17,14 +17,21 @@ type EnabledOption = boolean | (() => boolean);
17
17
  interface BaseReadOptions extends TagOptions {
18
18
  enabled?: EnabledOption;
19
19
  }
20
- interface BaseReadResult<TData, TError, TPluginResult = Record<string, unknown>> {
20
+ interface BaseReadResult<TData, TError, TPluginResult = Record<string, unknown>, TTriggerOptions = {
21
+ force?: boolean;
22
+ }> {
21
23
  data: Signal<TData | undefined>;
22
24
  error: Signal<TError | undefined>;
23
25
  loading: Signal<boolean>;
24
26
  fetching: Signal<boolean>;
25
27
  meta: Signal<TPluginResult>;
26
28
  abort: () => void;
27
- refetch: () => Promise<SpooshResponse<TData, TError>>;
29
+ /**
30
+ * Manually trigger a fetch.
31
+ *
32
+ * @param options - Optional override options (query, body, params) to use for this specific request
33
+ */
34
+ trigger: (options?: TTriggerOptions) => Promise<SpooshResponse<TData, TError>>;
28
35
  }
29
36
  interface BaseWriteResult<TData, TError, TOptions, TPluginResult = Record<string, unknown>> {
30
37
  trigger: (options?: TOptions) => Promise<SpooshResponse<TData, TError>>;
@@ -32,7 +39,6 @@ interface BaseWriteResult<TData, TError, TOptions, TPluginResult = Record<string
32
39
  error: Signal<TError | undefined>;
33
40
  loading: Signal<boolean>;
34
41
  meta: Signal<TPluginResult>;
35
- reset: () => void;
36
42
  abort: () => void;
37
43
  }
38
44
  type PageContext<TData, TRequest> = {
@@ -61,7 +67,7 @@ interface BaseInfiniteReadResult<TData, TError, TItem, TPluginResult = Record<st
61
67
  meta: Signal<TPluginResult>;
62
68
  fetchNext: () => Promise<void>;
63
69
  fetchPrev: () => Promise<void>;
64
- refetch: () => Promise<void>;
70
+ trigger: () => Promise<void>;
65
71
  abort: () => void;
66
72
  }
67
73
  type QueryRequestOptions = CoreRequestOptionsBase;
@@ -141,6 +147,33 @@ type ExtractResponseParamNames<T> = SuccessReturnType<T> extends {
141
147
  params: Record<infer K, unknown>;
142
148
  };
143
149
  } ? K extends string ? K : never : never;
150
+ type AwaitedReturnTypeTrigger<T> = T extends (...args: never[]) => infer R ? Awaited<R> : never;
151
+ type ExtractInputFromResponse<T> = T extends {
152
+ input: infer I;
153
+ } ? I : never;
154
+ type ExtractTriggerQuery<I> = I extends {
155
+ query: infer Q;
156
+ } ? {
157
+ query?: Q;
158
+ } : unknown;
159
+ type ExtractTriggerBody<I> = I extends {
160
+ body: infer B;
161
+ } ? {
162
+ body?: B;
163
+ } : unknown;
164
+ type ExtractTriggerParams<I> = I extends {
165
+ params: infer P;
166
+ } ? {
167
+ params?: P;
168
+ } : unknown;
169
+ type TriggerOptions<T> = ExtractInputFromResponse<AwaitedReturnTypeTrigger<T>> extends infer I ? [I] extends [never] ? {
170
+ force?: boolean;
171
+ } : ExtractTriggerQuery<I> & ExtractTriggerBody<I> & ExtractTriggerParams<I> & {
172
+ /** Force refetch even if data is cached */
173
+ force?: boolean;
174
+ } : {
175
+ force?: boolean;
176
+ };
144
177
  type ExtractMethodQuery<T> = ExtractMethodOptions<T> extends {
145
178
  query: infer Q;
146
179
  } ? Q : never;
@@ -313,7 +346,7 @@ declare function createInjectRead<TSchema, TDefaultError, TPlugins extends reado
313
346
  readResult: infer R_2;
314
347
  } ? R_2 : object : object : never : never) extends infer T_1 ? T_1 extends (TPlugins[number] extends infer T_2 ? T_2 extends TPlugins[number] ? T_2 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
315
348
  readResult: infer R_2;
316
- } ? R_2 : object : object : never : never) ? T_1 extends unknown ? (x: T_1) => void : never : never : never) extends (x: infer I) => void ? I : never, TReadOpts>> & ResponseInputFields<ExtractResponseQuery<TReadFn>, ExtractResponseBody<TReadFn>, ExtractResponseParamNames<TReadFn>>;
349
+ } ? R_2 : object : object : never : never) ? T_1 extends unknown ? (x: T_1) => void : never : never : never) extends (x: infer I) => void ? I : never, TReadOpts>, TriggerOptions<TReadFn>> & ResponseInputFields<ExtractResponseQuery<TReadFn>, ExtractResponseBody<TReadFn>, ExtractResponseParamNames<TReadFn>>;
317
350
 
318
351
  type SpooshAngularFunctions<TDefaultError, TSchema, TPlugins extends PluginArray> = {
319
352
  injectRead: ReturnType<typeof createInjectRead<TSchema, TDefaultError, TPlugins>>;
@@ -323,4 +356,4 @@ type SpooshAngularFunctions<TDefaultError, TSchema, TPlugins extends PluginArray
323
356
 
324
357
  declare function createAngularSpoosh<TSchema, TDefaultError, TPlugins extends PluginArray, TApi>(instance: SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins>): SpooshAngularFunctions<TDefaultError, TSchema, TPlugins>;
325
358
 
326
- export { type AngularOptionsMap, type BaseInfiniteReadOptions, type BaseInfiniteReadResult, type BaseReadOptions, type BaseReadResult, type BaseWriteResult, type EnabledOption, type ExtractMethodBody, type ExtractMethodData, type ExtractMethodError, type ExtractMethodOptions, type ExtractMethodQuery, type ExtractResponseBody, type ExtractResponseParamNames, type ExtractResponseQuery, type PageContext, type ReadApiClient, type ResponseInputFields, type SpooshInstanceShape, type WriteApiClient, type WriteResponseInputFields, createAngularSpoosh };
359
+ export { type AngularOptionsMap, type BaseInfiniteReadOptions, type BaseInfiniteReadResult, type BaseReadOptions, type BaseReadResult, type BaseWriteResult, type EnabledOption, type ExtractMethodBody, type ExtractMethodData, type ExtractMethodError, type ExtractMethodOptions, type ExtractMethodQuery, type ExtractResponseBody, type ExtractResponseParamNames, type ExtractResponseQuery, type PageContext, type ReadApiClient, type ResponseInputFields, type SpooshInstanceShape, type TriggerOptions, type WriteApiClient, type WriteResponseInputFields, createAngularSpoosh };
package/dist/index.d.ts CHANGED
@@ -17,14 +17,21 @@ type EnabledOption = boolean | (() => boolean);
17
17
  interface BaseReadOptions extends TagOptions {
18
18
  enabled?: EnabledOption;
19
19
  }
20
- interface BaseReadResult<TData, TError, TPluginResult = Record<string, unknown>> {
20
+ interface BaseReadResult<TData, TError, TPluginResult = Record<string, unknown>, TTriggerOptions = {
21
+ force?: boolean;
22
+ }> {
21
23
  data: Signal<TData | undefined>;
22
24
  error: Signal<TError | undefined>;
23
25
  loading: Signal<boolean>;
24
26
  fetching: Signal<boolean>;
25
27
  meta: Signal<TPluginResult>;
26
28
  abort: () => void;
27
- refetch: () => Promise<SpooshResponse<TData, TError>>;
29
+ /**
30
+ * Manually trigger a fetch.
31
+ *
32
+ * @param options - Optional override options (query, body, params) to use for this specific request
33
+ */
34
+ trigger: (options?: TTriggerOptions) => Promise<SpooshResponse<TData, TError>>;
28
35
  }
29
36
  interface BaseWriteResult<TData, TError, TOptions, TPluginResult = Record<string, unknown>> {
30
37
  trigger: (options?: TOptions) => Promise<SpooshResponse<TData, TError>>;
@@ -32,7 +39,6 @@ interface BaseWriteResult<TData, TError, TOptions, TPluginResult = Record<string
32
39
  error: Signal<TError | undefined>;
33
40
  loading: Signal<boolean>;
34
41
  meta: Signal<TPluginResult>;
35
- reset: () => void;
36
42
  abort: () => void;
37
43
  }
38
44
  type PageContext<TData, TRequest> = {
@@ -61,7 +67,7 @@ interface BaseInfiniteReadResult<TData, TError, TItem, TPluginResult = Record<st
61
67
  meta: Signal<TPluginResult>;
62
68
  fetchNext: () => Promise<void>;
63
69
  fetchPrev: () => Promise<void>;
64
- refetch: () => Promise<void>;
70
+ trigger: () => Promise<void>;
65
71
  abort: () => void;
66
72
  }
67
73
  type QueryRequestOptions = CoreRequestOptionsBase;
@@ -141,6 +147,33 @@ type ExtractResponseParamNames<T> = SuccessReturnType<T> extends {
141
147
  params: Record<infer K, unknown>;
142
148
  };
143
149
  } ? K extends string ? K : never : never;
150
+ type AwaitedReturnTypeTrigger<T> = T extends (...args: never[]) => infer R ? Awaited<R> : never;
151
+ type ExtractInputFromResponse<T> = T extends {
152
+ input: infer I;
153
+ } ? I : never;
154
+ type ExtractTriggerQuery<I> = I extends {
155
+ query: infer Q;
156
+ } ? {
157
+ query?: Q;
158
+ } : unknown;
159
+ type ExtractTriggerBody<I> = I extends {
160
+ body: infer B;
161
+ } ? {
162
+ body?: B;
163
+ } : unknown;
164
+ type ExtractTriggerParams<I> = I extends {
165
+ params: infer P;
166
+ } ? {
167
+ params?: P;
168
+ } : unknown;
169
+ type TriggerOptions<T> = ExtractInputFromResponse<AwaitedReturnTypeTrigger<T>> extends infer I ? [I] extends [never] ? {
170
+ force?: boolean;
171
+ } : ExtractTriggerQuery<I> & ExtractTriggerBody<I> & ExtractTriggerParams<I> & {
172
+ /** Force refetch even if data is cached */
173
+ force?: boolean;
174
+ } : {
175
+ force?: boolean;
176
+ };
144
177
  type ExtractMethodQuery<T> = ExtractMethodOptions<T> extends {
145
178
  query: infer Q;
146
179
  } ? Q : never;
@@ -313,7 +346,7 @@ declare function createInjectRead<TSchema, TDefaultError, TPlugins extends reado
313
346
  readResult: infer R_2;
314
347
  } ? R_2 : object : object : never : never) extends infer T_1 ? T_1 extends (TPlugins[number] extends infer T_2 ? T_2 extends TPlugins[number] ? T_2 extends SpooshPlugin<infer Types extends PluginTypeConfig> ? Types extends {
315
348
  readResult: infer R_2;
316
- } ? R_2 : object : object : never : never) ? T_1 extends unknown ? (x: T_1) => void : never : never : never) extends (x: infer I) => void ? I : never, TReadOpts>> & ResponseInputFields<ExtractResponseQuery<TReadFn>, ExtractResponseBody<TReadFn>, ExtractResponseParamNames<TReadFn>>;
349
+ } ? R_2 : object : object : never : never) ? T_1 extends unknown ? (x: T_1) => void : never : never : never) extends (x: infer I) => void ? I : never, TReadOpts>, TriggerOptions<TReadFn>> & ResponseInputFields<ExtractResponseQuery<TReadFn>, ExtractResponseBody<TReadFn>, ExtractResponseParamNames<TReadFn>>;
317
350
 
318
351
  type SpooshAngularFunctions<TDefaultError, TSchema, TPlugins extends PluginArray> = {
319
352
  injectRead: ReturnType<typeof createInjectRead<TSchema, TDefaultError, TPlugins>>;
@@ -323,4 +356,4 @@ type SpooshAngularFunctions<TDefaultError, TSchema, TPlugins extends PluginArray
323
356
 
324
357
  declare function createAngularSpoosh<TSchema, TDefaultError, TPlugins extends PluginArray, TApi>(instance: SpooshInstanceShape<TApi, TSchema, TDefaultError, TPlugins>): SpooshAngularFunctions<TDefaultError, TSchema, TPlugins>;
325
358
 
326
- export { type AngularOptionsMap, type BaseInfiniteReadOptions, type BaseInfiniteReadResult, type BaseReadOptions, type BaseReadResult, type BaseWriteResult, type EnabledOption, type ExtractMethodBody, type ExtractMethodData, type ExtractMethodError, type ExtractMethodOptions, type ExtractMethodQuery, type ExtractResponseBody, type ExtractResponseParamNames, type ExtractResponseQuery, type PageContext, type ReadApiClient, type ResponseInputFields, type SpooshInstanceShape, type WriteApiClient, type WriteResponseInputFields, createAngularSpoosh };
359
+ export { type AngularOptionsMap, type BaseInfiniteReadOptions, type BaseInfiniteReadResult, type BaseReadOptions, type BaseReadResult, type BaseWriteResult, type EnabledOption, type ExtractMethodBody, type ExtractMethodData, type ExtractMethodError, type ExtractMethodOptions, type ExtractMethodQuery, type ExtractResponseBody, type ExtractResponseParamNames, type ExtractResponseQuery, type PageContext, type ReadApiClient, type ResponseInputFields, type SpooshInstanceShape, type TriggerOptions, type WriteApiClient, type WriteResponseInputFields, createAngularSpoosh };
package/dist/index.js CHANGED
@@ -45,6 +45,7 @@ function createInjectRead(options) {
45
45
  const metaSignal = (0, import_core.signal)({});
46
46
  let currentController = null;
47
47
  let currentQueryKey = null;
48
+ let baseQueryKey = null;
48
49
  let currentSubscription = null;
49
50
  let currentResolvedTags = [];
50
51
  let prevContext = null;
@@ -99,12 +100,16 @@ function createInjectRead(options) {
99
100
  currentResolvedTags = resolvedTags;
100
101
  return controller;
101
102
  };
102
- const executeWithTracking = async (controller, force = false) => {
103
+ const executeWithTracking = async (controller, force = false, overrideOptions) => {
103
104
  const hasData = dataSignal() !== void 0;
104
105
  loadingSignal.set(!hasData);
105
106
  fetchingSignal.set(true);
106
107
  try {
107
- const response = await controller.execute(void 0, { force });
108
+ const execOptions = overrideOptions ? {
109
+ ...currentController?.getContext().requestOptions,
110
+ ...overrideOptions
111
+ } : void 0;
112
+ const response = await controller.execute(execOptions, { force });
108
113
  if (response.error) {
109
114
  errorSignal.set(response.error);
110
115
  } else {
@@ -145,6 +150,7 @@ function createInjectRead(options) {
145
150
  options: initialCapturedCall.options
146
151
  });
147
152
  createController(initialCapturedCall, initialResolvedTags, initialQueryKey);
153
+ baseQueryKey = initialQueryKey;
148
154
  loadingSignal.set(false);
149
155
  let wasEnabled = false;
150
156
  (0, import_core.effect)(
@@ -181,10 +187,11 @@ function createInjectRead(options) {
181
187
  inputInner.params = opts.params;
182
188
  }
183
189
  inputSignal.set(inputInner);
184
- const queryKeyChanged = queryKey !== currentQueryKey;
190
+ const baseQueryKeyChanged = queryKey !== baseQueryKey;
185
191
  const enabledChanged = isEnabled !== wasEnabled;
186
192
  wasEnabled = isEnabled;
187
- if (queryKeyChanged) {
193
+ if (baseQueryKeyChanged) {
194
+ baseQueryKey = queryKey;
188
195
  if (currentController) {
189
196
  prevContext = currentController.getContext();
190
197
  if (isMounted) {
@@ -267,15 +274,47 @@ function createInjectRead(options) {
267
274
  const abort = () => {
268
275
  currentController?.abort();
269
276
  };
270
- const refetch = () => {
271
- if (currentController) {
272
- if (!isMounted) {
273
- currentController.mount();
274
- isMounted = true;
277
+ const trigger = async (triggerOptions) => {
278
+ const { force = false, ...overrideOptions } = triggerOptions ?? {};
279
+ const hasOverrides = Object.keys(overrideOptions).length > 0;
280
+ if (!hasOverrides) {
281
+ if (!currentController) {
282
+ return Promise.resolve({ data: void 0, error: void 0 });
275
283
  }
276
- return executeWithTracking(currentController, true);
284
+ return executeWithTracking(currentController, force, void 0);
277
285
  }
278
- return Promise.resolve({ data: void 0, error: void 0 });
286
+ const selectorResult = captureSelector();
287
+ const capturedCall = selectorResult.call;
288
+ if (!capturedCall) {
289
+ return Promise.resolve({ data: void 0, error: void 0 });
290
+ }
291
+ const mergedOptions = {
292
+ ...capturedCall.options ?? {},
293
+ ...overrideOptions
294
+ };
295
+ const pathSegments = capturedCall.path.split("/").filter(Boolean);
296
+ const newQueryKey = stateManager.createQueryKey({
297
+ path: pathSegments,
298
+ method: capturedCall.method,
299
+ options: mergedOptions
300
+ });
301
+ if (newQueryKey === currentQueryKey && currentController) {
302
+ return executeWithTracking(currentController, force, overrideOptions);
303
+ }
304
+ const params = mergedOptions?.params;
305
+ const newResolvedPath = (0, import_core2.resolvePath)(pathSegments, params);
306
+ const newResolvedTags = (0, import_core2.resolveTags)(
307
+ tags !== void 0 ? { tags } : void 0,
308
+ newResolvedPath
309
+ );
310
+ const newController = createController(
311
+ { ...capturedCall, options: mergedOptions },
312
+ newResolvedTags,
313
+ newQueryKey
314
+ );
315
+ newController.mount();
316
+ isMounted = true;
317
+ return executeWithTracking(newController, force, void 0);
279
318
  };
280
319
  const result = {
281
320
  meta: metaSignal,
@@ -287,7 +326,7 @@ function createInjectRead(options) {
287
326
  loading: loadingSignal,
288
327
  fetching: fetchingSignal,
289
328
  abort,
290
- refetch
329
+ trigger
291
330
  };
292
331
  return result;
293
332
  };
@@ -333,14 +372,6 @@ function createInjectWrite(options) {
333
372
  currentSubscription();
334
373
  }
335
374
  });
336
- const reset = () => {
337
- if (currentQueryKey) {
338
- stateManager.deleteCache(currentQueryKey);
339
- }
340
- dataSignal.set(void 0);
341
- errorSignal.set(void 0);
342
- loadingSignal.set(false);
343
- };
344
375
  const abort = () => {
345
376
  currentController?.abort();
346
377
  };
@@ -431,7 +462,6 @@ function createInjectWrite(options) {
431
462
  data: dataSignal,
432
463
  error: errorSignal,
433
464
  loading: loadingSignal,
434
- reset,
435
465
  abort
436
466
  };
437
467
  return result;
@@ -730,7 +760,7 @@ function createInjectInfiniteRead(options) {
730
760
  fetchingPrevSignal.set(false);
731
761
  }
732
762
  };
733
- const refetch = async () => {
763
+ const trigger = async () => {
734
764
  if (!currentController) return;
735
765
  if (!isMounted) {
736
766
  currentController.mount();
@@ -763,7 +793,7 @@ function createInjectInfiniteRead(options) {
763
793
  canFetchPrev: canFetchPrevSignal,
764
794
  fetchNext,
765
795
  fetchPrev,
766
- refetch,
796
+ trigger,
767
797
  abort
768
798
  };
769
799
  return result;
package/dist/index.mjs CHANGED
@@ -30,6 +30,7 @@ function createInjectRead(options) {
30
30
  const metaSignal = signal({});
31
31
  let currentController = null;
32
32
  let currentQueryKey = null;
33
+ let baseQueryKey = null;
33
34
  let currentSubscription = null;
34
35
  let currentResolvedTags = [];
35
36
  let prevContext = null;
@@ -84,12 +85,16 @@ function createInjectRead(options) {
84
85
  currentResolvedTags = resolvedTags;
85
86
  return controller;
86
87
  };
87
- const executeWithTracking = async (controller, force = false) => {
88
+ const executeWithTracking = async (controller, force = false, overrideOptions) => {
88
89
  const hasData = dataSignal() !== void 0;
89
90
  loadingSignal.set(!hasData);
90
91
  fetchingSignal.set(true);
91
92
  try {
92
- const response = await controller.execute(void 0, { force });
93
+ const execOptions = overrideOptions ? {
94
+ ...currentController?.getContext().requestOptions,
95
+ ...overrideOptions
96
+ } : void 0;
97
+ const response = await controller.execute(execOptions, { force });
93
98
  if (response.error) {
94
99
  errorSignal.set(response.error);
95
100
  } else {
@@ -130,6 +135,7 @@ function createInjectRead(options) {
130
135
  options: initialCapturedCall.options
131
136
  });
132
137
  createController(initialCapturedCall, initialResolvedTags, initialQueryKey);
138
+ baseQueryKey = initialQueryKey;
133
139
  loadingSignal.set(false);
134
140
  let wasEnabled = false;
135
141
  effect(
@@ -166,10 +172,11 @@ function createInjectRead(options) {
166
172
  inputInner.params = opts.params;
167
173
  }
168
174
  inputSignal.set(inputInner);
169
- const queryKeyChanged = queryKey !== currentQueryKey;
175
+ const baseQueryKeyChanged = queryKey !== baseQueryKey;
170
176
  const enabledChanged = isEnabled !== wasEnabled;
171
177
  wasEnabled = isEnabled;
172
- if (queryKeyChanged) {
178
+ if (baseQueryKeyChanged) {
179
+ baseQueryKey = queryKey;
173
180
  if (currentController) {
174
181
  prevContext = currentController.getContext();
175
182
  if (isMounted) {
@@ -252,15 +259,47 @@ function createInjectRead(options) {
252
259
  const abort = () => {
253
260
  currentController?.abort();
254
261
  };
255
- const refetch = () => {
256
- if (currentController) {
257
- if (!isMounted) {
258
- currentController.mount();
259
- isMounted = true;
262
+ const trigger = async (triggerOptions) => {
263
+ const { force = false, ...overrideOptions } = triggerOptions ?? {};
264
+ const hasOverrides = Object.keys(overrideOptions).length > 0;
265
+ if (!hasOverrides) {
266
+ if (!currentController) {
267
+ return Promise.resolve({ data: void 0, error: void 0 });
260
268
  }
261
- return executeWithTracking(currentController, true);
269
+ return executeWithTracking(currentController, force, void 0);
262
270
  }
263
- return Promise.resolve({ data: void 0, error: void 0 });
271
+ const selectorResult = captureSelector();
272
+ const capturedCall = selectorResult.call;
273
+ if (!capturedCall) {
274
+ return Promise.resolve({ data: void 0, error: void 0 });
275
+ }
276
+ const mergedOptions = {
277
+ ...capturedCall.options ?? {},
278
+ ...overrideOptions
279
+ };
280
+ const pathSegments = capturedCall.path.split("/").filter(Boolean);
281
+ const newQueryKey = stateManager.createQueryKey({
282
+ path: pathSegments,
283
+ method: capturedCall.method,
284
+ options: mergedOptions
285
+ });
286
+ if (newQueryKey === currentQueryKey && currentController) {
287
+ return executeWithTracking(currentController, force, overrideOptions);
288
+ }
289
+ const params = mergedOptions?.params;
290
+ const newResolvedPath = resolvePath(pathSegments, params);
291
+ const newResolvedTags = resolveTags(
292
+ tags !== void 0 ? { tags } : void 0,
293
+ newResolvedPath
294
+ );
295
+ const newController = createController(
296
+ { ...capturedCall, options: mergedOptions },
297
+ newResolvedTags,
298
+ newQueryKey
299
+ );
300
+ newController.mount();
301
+ isMounted = true;
302
+ return executeWithTracking(newController, force, void 0);
264
303
  };
265
304
  const result = {
266
305
  meta: metaSignal,
@@ -272,7 +311,7 @@ function createInjectRead(options) {
272
311
  loading: loadingSignal,
273
312
  fetching: fetchingSignal,
274
313
  abort,
275
- refetch
314
+ trigger
276
315
  };
277
316
  return result;
278
317
  };
@@ -323,14 +362,6 @@ function createInjectWrite(options) {
323
362
  currentSubscription();
324
363
  }
325
364
  });
326
- const reset = () => {
327
- if (currentQueryKey) {
328
- stateManager.deleteCache(currentQueryKey);
329
- }
330
- dataSignal.set(void 0);
331
- errorSignal.set(void 0);
332
- loadingSignal.set(false);
333
- };
334
365
  const abort = () => {
335
366
  currentController?.abort();
336
367
  };
@@ -421,7 +452,6 @@ function createInjectWrite(options) {
421
452
  data: dataSignal,
422
453
  error: errorSignal,
423
454
  loading: loadingSignal,
424
- reset,
425
455
  abort
426
456
  };
427
457
  return result;
@@ -732,7 +762,7 @@ function createInjectInfiniteRead(options) {
732
762
  fetchingPrevSignal.set(false);
733
763
  }
734
764
  };
735
- const refetch = async () => {
765
+ const trigger = async () => {
736
766
  if (!currentController) return;
737
767
  if (!isMounted) {
738
768
  currentController.mount();
@@ -765,7 +795,7 @@ function createInjectInfiniteRead(options) {
765
795
  canFetchPrev: canFetchPrevSignal,
766
796
  fetchNext,
767
797
  fetchPrev,
768
- refetch,
798
+ trigger,
769
799
  abort
770
800
  };
771
801
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spoosh/angular",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "license": "MIT",
5
5
  "description": "Angular signals integration for Spoosh API client",
6
6
  "keywords": [
@@ -38,7 +38,7 @@
38
38
  "@angular/core": ">=16.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@spoosh/core": "0.7.0"
41
+ "@spoosh/core": "0.9.0"
42
42
  },
43
43
  "scripts": {
44
44
  "dev": "tsup --watch",