UNPKG

next

Version:

The React Framework

20 lines (19 loc) 988 B
import { workAsyncStorage } from '../app-render/work-async-storage.external'; import { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external'; /** * This function allows you to schedule callbacks to be executed after the current request finishes. */ export function after(task) { const workStore = workAsyncStorage.getStore(); const workUnitStore = workUnitAsyncStorage.getStore(); if (!workStore || !workUnitStore) { // TODO(after): the linked docs page talks about *dynamic* APIs, which after soon won't be anymore throw Object.defineProperty(new Error('`after` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context'), "__NEXT_ERROR_CODE", { value: "E468", enumerable: false, configurable: true }); } const { afterContext } = workStore; return afterContext.after(task, workUnitStore); } //# sourceMappingURL=after.js.map