@nanostores/query
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -27,3 +27,5 @@ import { MapStore, ReadableAtom } from "nanostores"; | ||
}; | ||
export declare type FetcherStore<T = any, E = any> = MapStore<FetcherValue<T, E>>; | ||
export declare type FetcherStore<T = any, E = any> = MapStore<FetcherValue<T, E>> & { | ||
key?: string; | ||
}; | ||
export declare type FetcherStoreCreator<T = any, E = Error> = (keys: KeyInput, settings?: CommonSettings<T>) => FetcherStore<T, E>; | ||
@@ -30,0 +32,0 @@ export declare type ManualMutator<Data = void, Result = unknown> = (args: { |
@@ -86,5 +86,6 @@ import { map, onStart, onStop, atom } from "nanostores"; | ||
[keyStore, keysInternalUnsub] = getKeyStore(keyInput); | ||
keyUnsub = keyStore.listen((currentKeys) => { | ||
keyUnsub = keyStore.subscribe((currentKeys) => { | ||
if (currentKeys) { | ||
const [newKey, keyParts] = currentKeys; | ||
fetcherStore.key = newKey; | ||
runFetcher([newKey, keyParts], fetcherStore, settings); | ||
@@ -94,3 +95,3 @@ prevKey = newKey; | ||
} else { | ||
prevKey = prevKeyParts = void 0; | ||
fetcherStore.key = prevKey = prevKeyParts = void 0; | ||
} | ||
@@ -245,5 +246,4 @@ }); | ||
} | ||
keyParts.push(key.get()); | ||
unsubs.push( | ||
key.listen((newValue) => { | ||
key.subscribe((newValue) => { | ||
keyParts[i] = newValue; | ||
@@ -250,0 +250,0 @@ setKeyStoreValue(); |
{ | ||
"name": "@nanostores/query", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Tiny remote data fetching library for Nano Stores", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -6,8 +6,8 @@ # Nano Stores Query | ||
A data fetcher for [Nano Stores](https://github.com/nanostores/nanostores). | ||
A tiny data fetcher for [Nano Stores](https://github.com/nanostores/nanostores). | ||
- **Small**. 1.65 Kb (minified and gzipped). | ||
- **Familiar DX**. If you've used [`swr`](https://swr.vercel.app/) or | ||
[`react-query`](https://react-query-v3.tanstack.com/), you already know how nanoquery | ||
works. | ||
[`react-query`](https://react-query-v3.tanstack.com/), you'll get the same treatment, | ||
but for 10-20% of the size. | ||
- **Built-in cache**. `stale-while-revalidate` caching from | ||
@@ -22,2 +22,4 @@ [HTTP RFC 5861](https://tools.ietf.org/html/rfc5861). User rarely sees unnecessary | ||
[router](https://github.com/nanostores/router), and the rest. | ||
- **Transport agnostic**. Use GraphQL, REST codegen, plain fetch or anything, | ||
that returns Promises. | ||
@@ -24,0 +26,0 @@ <a href="https://evilmartians.com/?utm_source=nanostores-query"> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28273
600
170