Socket
Socket
Sign inDemoInstall

@libre/atom

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.1 to 1.2.2

34

dist/index.esm.js

@@ -59,7 +59,13 @@ let nextAtomUid = 0;

addChangeHandler(countAtom, "log", (state) => { console.log(state) })
addChangeHandler(countAtom, "log", ({current, previous}) => {
console.log(previous, current)
})
swap(countAtom, (state) => ({ count: state.count + 1 }))
// stdout logs: { count: 1 }
// stdout logs:
// { count: 0 }
// { count: 1 }
```

@@ -73,2 +79,26 @@ */

* when the state of `atom` changes.
*
* * @example
```js
import {Atom, addChangeHandler, removeChangeHandler, swap} from '@libre/atom'
const countAtom = Atom.of({ count: 0 })
addChangeHandler(countAtom, "log", ({current, previous}) => {
console.log(previous, current)
})
swap(countAtom, (state) => ({ count: state.count + 1 }))
// stdout logs:
// { count: 0 }
// { count: 1 }
removeChangeHandler(atom, "log")
swap(countAtom, (state) => ({ count: state.count + 1 }))
// nothing is logged
```
*/

@@ -75,0 +105,0 @@ function removeChangeHandler(atom, key) {

@@ -14,7 +14,13 @@ import { Atom } from "./atom";

addChangeHandler(countAtom, "log", (state) => { console.log(state) })
addChangeHandler(countAtom, "log", ({current, previous}) => {
console.log(previous, current)
})
swap(countAtom, (state) => ({ count: state.count + 1 }))
// stdout logs: { count: 1 }
// stdout logs:
// { count: 0 }
// { count: 1 }
```

@@ -29,3 +35,27 @@ */

* when the state of `atom` changes.
*
* * @example
```js
import {Atom, addChangeHandler, removeChangeHandler, swap} from '@libre/atom'
const countAtom = Atom.of({ count: 0 })
addChangeHandler(countAtom, "log", ({current, previous}) => {
console.log(previous, current)
})
swap(countAtom, (state) => ({ count: state.count + 1 }))
// stdout logs:
// { count: 0 }
// { count: 1 }
removeChangeHandler(atom, "log")
swap(countAtom, (state) => ({ count: state.count + 1 }))
// nothing is logged
```
*/
export declare function removeChangeHandler<S>(atom: Atom<S>, key: string): void;

4

dist/types/internal-state.d.ts
import { Atom } from "./atom";
import { AtomConstructorOptions, DeepImmutable } from "./internal-types";
import { AtomConstructorOptions } from "./internal-types";
/** @ignore */
export declare function _useNextAtomId(): number;
/** @ignore */
export declare function _getState<S>(atom: Atom<S>): DeepImmutable<S>;
export declare function _getState<S>(atom: Atom<S>): S;
/** @ignore */

@@ -8,0 +8,0 @@ export declare function _setState<S>(atom: Atom<S>, state: S): void;

import { Atom } from "./atom";
import { DeepImmutable } from "./internal-types";
/**

@@ -22,2 +21,2 @@ * Swaps `atom`'s state with the value returned from applying `updateFn` to `atom`'s

*/
export declare function swap<S>(atom: Atom<S>, updateFn: (state: DeepImmutable<S>) => S): void;
export declare function swap<S>(atom: Atom<S>, updateFn: (state: S) => S): void;

@@ -92,3 +92,3 @@ {

"unpkg": "https://unpkg.com/@libre/atom",
"version": "1.2.1"
"version": "1.2.2"
}

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc