recoil#RecoilValue TypeScript Examples
The following examples show how to use
recoil#RecoilValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecoilNexus.tsx From recoil-nexus with MIT License | 6 votes |
export default function RecoilNexus() {
nexus.get = useRecoilCallback<[atom: RecoilValue<any>], any>(({ snapshot }) =>
function <T>(atom: RecoilValue<T>) {
return snapshot.getLoadable(atom).contents
}, [])
nexus.getPromise = useRecoilCallback<[atom: RecoilValue<any>], Promise<any>>(({ snapshot }) =>
function <T>(atom: RecoilValue<T>) {
return snapshot.getPromise(atom)
}, [])
nexus.set = useRecoilCallback(({ set }) => set, [])
nexus.reset = useRecoilCallback(({ reset }) => reset, [])
return null
}
Example #2
Source File: RecoilNexus.tsx From recoil-nexus with MIT License | 5 votes |
export function getRecoil<T>(atom: RecoilValue<T>): T {
return nexus.get!(atom)
}
Example #3
Source File: RecoilNexus.tsx From recoil-nexus with MIT License | 5 votes |
export function getRecoilPromise<T>(atom: RecoilValue<T>): Promise<T> {
return nexus.getPromise!(atom)
}