scrivito
Version:
Scrivito is a professional, yet easy to use SaaS Enterprise Content Management Service, built for digital agencies and medium to large businesses. It is completely maintenance-free, cost-effective, and has unprecedented performance and security.
15 lines (11 loc) • 419 B
text/typescript
import { capture, isCurrentlyCapturing } from 'scrivito_sdk/loadable';
/** Evaluate the loadable function fn, without requiring a loading context.
* If called with a loading context, loading will be triggered. Otherwise not.
*/
export function withOptionalLoading<T>(fn: () => T): T {
const captured = capture(fn);
if (isCurrentlyCapturing()) {
captured.forwardToCurrent();
}
return captured.result;
}