UNPKG

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.

17 lines (14 loc) 491 B
import { runAndCatchErrorsWhileLoading } from 'scrivito_sdk/loadable'; /** Evaluate the loadableFunction and return its result, if fully loaded. * Otherwise, return the default. * * Must be called with a loading context. * Loading of `loadableFunction` is triggered. */ export function loadWithDefault<T, S>( theDefault: T, loadableFunction: () => S ): T | S { const run = runAndCatchErrorsWhileLoading(loadableFunction); return run.allDataLoaded ? run.result : theDefault; }