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.0.4 to 0.0.5

7

dist/nanoquery.js

@@ -25,2 +25,3 @@ import { map, onStart, onStop, atom } from "nanostores";

store.set(v);
events.emit(SET_KEY, key, v);
}

@@ -141,2 +142,6 @@ }, setKey = (k, v) => {

}
}),
events.on(SET_KEY, (key, value) => {
if (key === prevKey && fetcherStore.value !== value)
fetcherStore.set(value);
})

@@ -257,3 +262,3 @@ );

};
const FOCUS = 1, RECONNECT = 2, INVALIDATE_KEYS = 3, MUTATE_CACHE = 4;
const FOCUS = 1, RECONNECT = 2, INVALIDATE_KEYS = 3, MUTATE_CACHE = 4, SET_KEY = 5;
const subscribe = (name, fn) => {

@@ -260,0 +265,0 @@ const isServer = typeof window === "undefined";

2

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

@@ -5,0 +5,0 @@ "scripts": {

@@ -170,1 +170,27 @@ # Nano Stores Query

```
## Recipes
### Local state and Pagination
All examples above use module-scoped stores, therefore they can only have a single
data point stored. But what if you need, say, a store that fetches data based on
component state? Nano Stores do not limit you in any way, you can easily achieve
this by creating a store instance limited to a single component:
```tsx
const createStore = (id: string) => () =>
createFetcherStore<{ avatarUrl: string }>(`/api/user/${id}`);
const UserAvatar: FC<{ id: string }> = ({ id }) => {
const [$user] = useState(createStore(id));
const { data } = useStore($user);
if (!data) return null;
return <img src={data.avatarUrl} />;
};
```
This way you can leverage all nanoquery features, like cache or refetching, but
not give up the flexibility of component-level data fetching.

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