The discardAfter(deferFn, interval) function takes a deferred function and applies a custom discard_after attribute. By default, the discard_after is not set.

Deprecated

Prefer assignOptions() as discardAfter() will be dropped in 2.0.

The discardAfter(deferFn, interval) function takes a deferred function and applies a custom discard_after attribute. By default, the discard_after is not set.

Example:

import { discardAfter } from "@defer/client";
import { sayHello } from "./defer/sayHello";

const delayedSayHello = discardAfter(sayHello, "1h");
await delayedSayHello("John Doe");