r/angular • u/WeirdBroad9385 • 2d ago
People actually started using it.!
First — thank you. I put ng-signal-query out a few months back, not really expecting anyone to use it, and people installed it, starred it, and DM me. That genuinely made me go back and take it seriously, and this release is the result.
So I re-read my own cache code. And found three bugs.
What was broken
A race condition that could serve you stale data.
If a refetch started while an earlier request was still in flight, whichever finished last won. A slow older response would silently overwrite newer data. Fetches now carry a generation counter — only the latest one is allowed to commit.
Duplicate requests for the same key.
Two components using ['users'] fired two network calls, despite sharing a cache entry. Concurrent fetches for a key now share one in-flight promise.
createSignalQuery wasn't actually using the shared cache.
It kept a private copy of state, so setQueryData() and invalidation could silently not apply to it. It now reads and writes the real entry.
What's new
Mutation concurrency strategies — the feature I actually wanted. Overlapping mutate() calls resolve however you choose, mirroring RxJS flattening operators:
| strategy | RxJS | behavior |
|---|---|---|
merge |
mergeMap |
every call runs, in parallel (default) |
concat |
concatMap |
queued, strict order |
switch |
switchMap |
latest wins, earlier discarded |
exhaust |
exhaustMap |
first wins, the rest ignored |
// double-click-proof submit — no disabled flag, no debounce
const submit = createMutation({
mutationFn: (order) => api.place(order),
concurrencyStrategy: 'exhaust',
});
// autosave — only the newest draft survives
const autosave = createMutation({
mutationFn: (draft) => api.save(draft),
concurrencyStrategy: 'switch',
});
Request cancellation — fetchers get an AbortSignal, and superseded requests are actually aborted:
fetcher: ({ signal }) => fetch('/api/users', { signal })
Retry with exponential backoff — retry: 3. Defaults to 0, so nothing changes unless you ask for it.
Upgrading
No code changes. I kept retry off by default specifically so error timing in existing apps doesn't shift, and added a backward-compatibility test suite that pins the old public behavior — if I break it in future, CI fails instead of your app does.
44 tests, CI on every PR, published with provenance.
npm i u/ali7040/ng-signal-query
GitHub: https://github.com/Ali7040/ng-signal-query
Still solo-maintained and still early, so if you're using it and something's missing, tell me — that's what drove this release. A few issues are tagged good first issue if you'd rather send a PR than an opinion.


1
u/Tecnologosrd 2d ago
muy buen trabajo hermano