import { RecoilValue , RecoilState , useRecoilCallback } from 'recoil' ; interface Nexus { get ? : < T > ( atom : RecoilValue < T > ) => T ; getPromise ? : < T > ( atom : RecoilValue < T > ) => Promise < T > ; set ? : < T > ( atom : RecoilState < T > , valOrUpdater : T | ( ( currVal : T ) => T ) ) => void ; reset ? : ( atom : RecoilState < any > ) => void ; } const nexus = { } ; export default function RecoilNexus ( ) { nexus . get = useRecoilCallback < [ atom : RecoilValue < any > ] , any > ( ( { snapshot } ) => function < T > ( atom ) { return snapshot . getLoadable ( atom ) . contents ; } , [ ] ) ; nexus . getPromise = useRecoilCallback < [ atom : RecoilValue < any > ] , Promise < any > > ( ( { snapshot } ) => function < T > ( atom ) { return snapshot . getPromise ( atom ) ; } , [ ] ) ; nexus . set = useRecoilCallback ( ( { set } ) => set , [ ] ) ; nexus . reset = useRecoilCallback ( ( { reset } ) => reset , [ ] ) ; return null ; } export function getRecoil < T > ( atom ) { return nexus . get ! ( atom ) ; } export function getRecoilPromise < T > ( atom ) { return nexus . getPromise ! ( atom ) ; } export function setRecoil < T > ( atom , valOrUpdater ) { nexus . set ! ( atom , valOrUpdater ) ; } export function resetRecoil ( atom ) { nexus . reset ! ( atom ) ; }