Socket
Socket
Sign inDemoInstall

recoil-nexus

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recoil-nexus - npm Package Compare versions

Comparing version 0.2.51 to 0.3.0

3

build/RecoilNexus.d.ts
import { RecoilState } from 'recoil';
export default function RecoilNexus(): null;
export declare function getRecoil<T>(atom: RecoilState<T>): Promise<T>;
export declare function getRecoil<T>(atom: RecoilState<T>): T;
export declare function getRecoilPromise<T>(atom: RecoilState<T>): Promise<T>;
export declare function setRecoil<T>(atom: RecoilState<T>, value: T): void;

@@ -6,13 +6,15 @@ import { useRecoilCallback } from 'recoil';

var snapshot = _a.snapshot;
return function (_a) {
var atom = _a.atom, resolve = _a.resolve;
resolve(snapshot.getPromise(atom));
return function (atom) {
return snapshot.getLoadable(atom).contents;
};
}, []);
nexus.getPromise = useRecoilCallback(function (_a) {
var snapshot = _a.snapshot;
return function (atom) {
return snapshot.getPromise(atom);
};
}, []);
nexus.set = useRecoilCallback(function (_a) {
var set = _a.set;
return function (_a) {
var atom = _a.atom, value = _a.value;
set(atom, value);
};
return set;
}, []);

@@ -22,9 +24,10 @@ return null;

export function getRecoil(atom) {
return new Promise(function (resolve) {
nexus.get({ atom: atom, resolve: resolve });
});
return nexus.get(atom);
}
export function getRecoilPromise(atom) {
return nexus.getPromise(atom);
}
export function setRecoil(atom, value) {
nexus.set({ atom: atom, value: value });
nexus.set(atom, value);
}
//# sourceMappingURL=RecoilNexus.js.map
{
"name": "recoil-nexus",
"version": "0.2.51",
"version": "0.3.0",
"description": "A small Typescript package to access your Recoil atoms outside of React components.",

@@ -5,0 +5,0 @@ "main": "build/RecoilNexus.js",

@@ -49,3 +49,4 @@ # R E C O I L - N E X U S

| :---------- | :-------------------------------------------------------- |
| `getRecoil` | getter function, returns a promise |
| `getRecoil` | getter function |
| `getRecoilPromise` | getter function, returns a promise. To be used with asynchronous selectors. |
| `setRecoil` | setter function, pass value to be set as second parameter |

@@ -58,4 +59,4 @@

export default async function toggleLoading() {
const loading = await getRecoil(loadingState);
export default function toggleLoading() {
const loading = getRecoil(loadingState);
setRecoil(loadingState, !loading);

@@ -90,3 +91,3 @@ }

Original credits to [VeepCream](https://github.com/VeepCream)'s [recoil-outside](https://www.npmjs.com/package/recoil-outside) Javascript implementation.
In this Typescript package, I decided to remove RxJS and rely on promises only.
Kudos to [VeepCream](https://github.com/VeepCream)'s [recoil-outside](https://www.npmjs.com/package/recoil-outside) original idea and Javascript implementation.
In this Typescript port/enhancement, I decided to remove RxJS and rely on native Recoil promises and loadables only.

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