Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nanostores/query

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nanostores/query - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

6

dist/factory.d.ts

@@ -45,2 +45,7 @@ import { PlatformCompat } from './platforms/type';

};
type LazyFetchValue<T = any, E = any> = {
data: T;
} | {
error: E;
};
export type FetcherStore<T = any, E = any> = MapStore<FetcherValue<T, E>> & {

@@ -52,2 +57,3 @@ _: Symbol;

mutate: (data?: T) => void;
fetch: () => Promise<LazyFetchValue<T, E>>;
};

@@ -54,0 +60,0 @@ export type FetcherStoreCreator<T = any, E = Error> = (keys: KeyInput, settings?: CommonSettings<T>) => FetcherStore<T, E>;

@@ -146,2 +146,13 @@ import { map, onStart, onStop, atom, batched, startTask } from 'nanostores';

};
fetcherStore.fetch = async () => {
let resolve;
const promise = new Promise((r) => resolve = r);
const unsub = fetcherStore.listen(({ error, data }) => {
if (error)
resolve({ error });
if (data)
resolve({ data });
});
return promise.finally(unsub);
};
let keysInternalUnsub, prevKey, prevKeyParts, keyUnsub, keyStore;

@@ -148,0 +159,0 @@ let evtUnsubs = [];

4

package.json
{
"name": "@nanostores/query",
"version": "0.3.2",
"version": "0.3.3",
"description": "Tiny remote data fetching library for Nano Stores",

@@ -89,3 +89,3 @@ "scripts": {

},
"limit": "1862 B"
"limit": "1924 B"
}

@@ -92,0 +92,0 @@ ],

@@ -289,2 +289,13 @@ # Nano Stores Query

### Lazy fetcher
Sometimes you don't want a store, you just want an async function that's gonna handle the errors and leverage the cache (perform cache lookup, save data in there upon successful execution, etc.).
For that case use `fetcherStore.fetch` function. It will always resolve with the same data type as store itself (`error` and `data` only).
Few gotchas:
- it will execute against currently set keys (no way to customize them for the call);
- it will still leverage deduplication.
### Dependencies, but not in keys

@@ -291,0 +302,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc