silverwolf-x's picture
download
raw
774 Bytes
import { workAsyncStorage } from '../app-render/work-async-storage.external'
export type AfterTask<T = unknown> = Promise<T> | AfterCallback<T>
export type AfterCallback<T = unknown> = () => T | Promise<T>
/**
* This function allows you to schedule callbacks to be executed after the current request finishes.
*/
export function after<T>(task: AfterTask<T>): void {
const workStore = workAsyncStorage.getStore()
if (!workStore) {
// TODO(after): the linked docs page talks about *dynamic* APIs, which after soon won't be anymore
throw new Error(
'`after` was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context'
)
}
const { afterContext } = workStore
return afterContext.after(task)
}

Xet Storage Details

Size:
774 Bytes
·
Xet hash:
53688f3336032d1405e9d4a40d122b18cb4fdff05429eb3d8d8cb234fff88f25

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.