in packages/recoil/recoil_values/Recoil_selector.js [725:817]
throw err(
'Callbacks from getCallback() should only be called asynchronously after the selector is evalutated. It can be used for selectors to return objects with callbacks that can work with Recoil state without a subscription.',
);
}
invariant(recoilValue != null, 'Recoil Value can never be null');
return recoilCallback<Args, Return, {node: RecoilState<T>}>(
store,
fn,
args,
{node: (recoilValue: any)}, // flowlint-line unclear-type:off
);
};
};
try {
result = get({get: getRecoilValue, getCallback});
result = isRecoilValue(result) ? getRecoilValue(result) : result;
if (isLoadable(result)) {
if (result.state === 'hasError') {
resultIsError = true;
}
result = (result: ValueLoadableType<T>).contents;
}
if (isPromise(result)) {
result = wrapPendingPromise(
store,
result,
state,
depValues,
executionId,
loadingDepsState,
).finally(finishEvaluation);
} else {
finishEvaluation();
}
result = result instanceof WrappedValue ? result.value : result;
} catch (errorOrDepPromise) {
result = errorOrDepPromise;
if (isPromise(result)) {
result = wrapPendingDependencyPromise(
store,
result,
state,
depValues,
executionId,
loadingDepsState,
).finally(finishEvaluation);
} else {
resultIsError = true;
finishEvaluation();
}
}
if (resultIsError) {
loadable = loadableWithError(result);
} else if (isPromise(result)) {
loadable = loadableWithPromise<T>(result);
} else {
loadable = loadableWithValue<T>(result);
}
duringSynchronousExecution = false;
setDepsInStore(store, state, deps, executionId);
return [loadable, depValues];
}
function getValFromCacheAndUpdatedDownstreamDeps(
store: Store,
state: TreeState,
): ?Loadable<T> {
const depsAfterCacheDone = new Set();
const executionInfo = getExecutionInfo(store);
let cachedVal;
try {
cachedVal = cache.get(
nodeKey => {
invariant(
typeof nodeKey === 'string',
'Cache nodeKey is type string',
);
const loadable = getCachedNodeLoadable(store, state, nodeKey);
return loadable.contents;
},
{
onNodeVisit: node => {
if (node.type === 'branch' && node.nodeKey !== key) {