recoil-nexus
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -1,2 +0,2 @@ | ||
import { RecoilValue, RecoilState } from 'recoil'; | ||
import { RecoilState, RecoilValue } from 'recoil'; | ||
export default function RecoilNexus(): null; | ||
@@ -3,0 +3,0 @@ export declare function getRecoil<T>(atom: RecoilValue<T>): T; |
@@ -5,5 +5,6 @@ "use strict"; | ||
var recoil_1 = require("recoil"); | ||
var recoil_2 = require("recoil"); | ||
var nexus = {}; | ||
function RecoilNexus() { | ||
nexus.get = (0, recoil_1.useRecoilCallback)(function (_a) { | ||
nexus.get = (0, recoil_2.useRecoilCallback)(function (_a) { | ||
var snapshot = _a.snapshot; | ||
@@ -14,3 +15,3 @@ return function (atom) { | ||
}, []); | ||
nexus.getPromise = (0, recoil_1.useRecoilCallback)(function (_a) { | ||
nexus.getPromise = (0, recoil_2.useRecoilCallback)(function (_a) { | ||
var snapshot = _a.snapshot; | ||
@@ -21,12 +22,18 @@ return function (atom) { | ||
}, []); | ||
nexus.set = (0, recoil_1.useRecoilCallback)(function (_a) { | ||
var transact_UNSTABLE = _a.transact_UNSTABLE; | ||
return function (atom, valOrUpdater) { | ||
transact_UNSTABLE(function (_a) { | ||
var set = _a.set; | ||
set(atom, valOrUpdater); | ||
}); | ||
var getInfo = (0, recoil_1.useGetRecoilValueInfo_UNSTABLE)(); | ||
var transact = (0, recoil_2.useRecoilTransaction_UNSTABLE)(function (_a) { | ||
var set = _a.set; | ||
return set; | ||
}); | ||
nexus.set = (0, recoil_2.useRecoilCallback)(function (_a) { | ||
var set = _a.set; | ||
return function (recoilState, valOrUpdater) { | ||
var update = { | ||
"atom": transact, | ||
"selector": set | ||
}[getInfo(recoilState).type]; | ||
update(recoilState, valOrUpdater); | ||
}; | ||
}, []); | ||
nexus.reset = (0, recoil_1.useRecoilCallback)(function (_a) { | ||
nexus.reset = (0, recoil_2.useRecoilCallback)(function (_a) { | ||
var reset = _a.reset; | ||
@@ -33,0 +40,0 @@ return reset; |
{ | ||
"name": "recoil-nexus", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "A small Typescript package to access your Recoil atoms outside of React components.", | ||
@@ -5,0 +5,0 @@ "main": "build/RecoilNexus.js", |
@@ -22,3 +22,2 @@ { | ||
"strictNullChecks": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
@@ -25,0 +24,0 @@ "noUnusedParameters": true, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10967
140