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.

20 lines (16 loc) 592 B
import { capture } from 'scrivito_sdk/loadable'; /** run the given functions, loading them serially. * * both functions are always run, but loading of the second function only starts * after loading of the first function has finished. */ export function loadSerial<S, T>( firstFn: () => S, secondFn: (input: S) => T ): T { const firstCaptured = capture(firstFn); firstCaptured.forwardToCurrent(); const secondCaptured = capture(() => secondFn(firstCaptured.result)); if (firstCaptured.isAllDataLoaded()) secondCaptured.forwardToCurrent(); return secondCaptured.result; }