Socket
Socket
Sign inDemoInstall

valtio

Package Overview
Dependencies
Maintainers
2
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valtio - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

2

index.cjs.js

@@ -202,3 +202,3 @@ 'use strict';

exports.proxy = createProxy;
exports.subscribeProxy = subscribe;
exports.subscribe = subscribe;
exports.useProxy = useProxy;
declare const createProxy: <T extends object>(initialObject?: T) => T;
declare const subscribe: (proxy: any, callback: () => void) => () => void;
declare const useProxy: <T extends object>(proxy: T) => T;
export { createProxy as proxy, useProxy, subscribe as subscribeProxy };
export { createProxy as proxy, useProxy, subscribe };

@@ -197,3 +197,3 @@ var valtio = (function (exports, react, proxyCompare, useSubscription) {

exports.proxy = createProxy;
exports.subscribeProxy = subscribe;
exports.subscribe = subscribe;
exports.useProxy = useProxy;

@@ -200,0 +200,0 @@

@@ -183,2 +183,2 @@ import { useMemo, useRef, useEffect } from 'react';

export { createProxy as proxy, subscribe as subscribeProxy, useProxy };
export { createProxy as proxy, subscribe, useProxy };
{
"name": "valtio",
"private": false,
"version": "0.2.1",
"version": "0.2.2",
"description": "💊 Valtio makes proxy-state simple ",

@@ -6,0 +6,0 @@ "main": "index.cjs.js",

@@ -34,2 +34,4 @@ ![](/readme.svg)

const snapshot = useProxy(state)
// Rule of thumb: read from snapshots, mutate the source
// The component renders when the snapshot-reads change
return (

@@ -44,4 +46,17 @@ <div>

### Subscribe from anywhere
```js
import { subscribe } from 'valtio'
// Suscribe to all state changes
const unsubscribe = subscribe(state, () => console.log(`state has changed to ${state}`))
// Unsubscribe by calling the result
unsubscribe()
// Subscribe to a portion of state
subscribe(state.foo, () => console.log(`state.foo has changed to ${state.foo}`))
```
**And that's it!**
</details>
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