recoil-nexus
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,6 +0,5 @@ | ||
/// <reference types="react" /> | ||
import { RecoilState } from 'recoil'; | ||
export default function RecoilNexus(): JSX.Element; | ||
export default function RecoilNexus(): null; | ||
export declare function useRecoilNexusValue<T>(atom: RecoilState<T>): () => Promise<T>; | ||
export declare function useRecoilNexusSetValue<T>(atom: RecoilState<T>): (v: T) => void; | ||
export declare function useRecoilNexus<T>(atom: RecoilState<T>): [() => Promise<T>, (v: T) => void]; |
@@ -37,3 +37,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import React from 'react'; | ||
import { useRecoilCallback } from 'recoil'; | ||
import { Subject } from 'rxjs'; | ||
@@ -45,14 +45,34 @@ var nexus = { | ||
export default function RecoilNexus() { | ||
// const getAtom = useRecoilCallback(({ snapshot }) => | ||
// async function <T>(atom: RecoilState<T>, subject: Subject<T>) { | ||
// const value = await snapshot.getPromise(atom); | ||
// subject.next(value) | ||
// }, []) | ||
// nexus.get.subscribe({ next: ({atom, subject}) => getAtom(atom, subject) }) | ||
// const setAtom = useRecoilCallback(({ set }) => | ||
// function <T>(atom: RecoilState<T>, value: T) { | ||
// set(atom, value) | ||
// }, []) | ||
// nexus.set.subscribe({ next: ({ atom, value }) => setAtom(atom, value) }); | ||
return React.createElement("div", null, "TEst"); | ||
var getAtom = useRecoilCallback(function (_a) { | ||
var snapshot = _a.snapshot; | ||
return function (atom, subject) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var value; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, snapshot.getPromise(atom)]; | ||
case 1: | ||
value = _a.sent(); | ||
subject.next(value); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
}, []); | ||
nexus.get.subscribe({ next: function (_a) { | ||
var atom = _a.atom, subject = _a.subject; | ||
return getAtom(atom, subject); | ||
} }); | ||
var setAtom = useRecoilCallback(function (_a) { | ||
var set = _a.set; | ||
return function (atom, value) { | ||
set(atom, value); | ||
}; | ||
}, []); | ||
nexus.set.subscribe({ next: function (_a) { | ||
var atom = _a.atom, value = _a.value; | ||
return setAtom(atom, value); | ||
} }); | ||
return null; | ||
} | ||
@@ -59,0 +79,0 @@ export function useRecoilNexusValue(atom) { |
{ | ||
"name": "recoil-nexus", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A small Typescript package to peep and inject values in your Recoil atoms outside of React components.", | ||
@@ -5,0 +5,0 @@ "main": "build/RecoilNexus.js", |
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
9826
180