Releases: defer-run/defer.client
Releases · defer-run/defer.client
v1.13.0
Minor Changes
-
#102
5613d53
Thanks @charlypoly! - AddassignOptions()
helperassignOptions
is helpful to change the behavior of a given Background Function
by combining multiple options such asdelay
,metadata
ordiscardAfter
:import { assignOptions, delay } from "@defer/client"; import handleStripeWebhookFn from "./defer/handleStripeWebhook.js"; // ... const handleStripeWebhook = assignOptions(handleStripeWebhookFn, { discardAfter: '12h' // process webhooks in the right order delay: event.created + 60 * 10, // add metadata for the the Defer Console metadata: { livemode: event.livemode, type: event.type, apiVersion: event.api_version, }, }); handleStripeWebhook(event.id) .then((executionID) => { response.sendStatus( 200, "application/json", JSON.stringify({ executionID }) ); }) .catch((err) => { response.sendStatus(400); }); // ...
v1.12.1
v1.11.0
v1.10.0
v1.9.0
v1.8.1
Patch Changes
- #82
73a96d9
Thanks @charlypoly! - Remove unnecessarypeerDependencies
onnext
andreact
v1.8.0
v1.7.2
Patch Changes
- #78
8477826
Thanks @charlypoly! - fix ESM compat
v1.7.1
Patch Changes
- #76
54ec6f7
Thanks @charlypoly! - Typings fixes on 1.7.0
v1.7.0
Minor Changes
-
#66
b9973d5
Thanks @charlypoly! - Introducing@defer/client/next
integrationThis release introduces two new helpers that makes Defer deeply integrated with NextJS:
asNextRoute()
: used in combination ofuseDeferRoute()
to trigger background functions from Client-side ComponentsuseDeferRoute()
: trigger and wait for the result of a background functions from Client-side Components
Next API Routes
import { asNextRoute } from "@defer/client/next"; import createThumbnails from "../../defer/createThumbnails"; const { GetHandler, PostHandler } = asNextRoute(createThumbnails); export const GET = GetHandler; export const POST = PostHandler;
React client-side component
import { useDeferRoute } from "@defer/client/next"; import createThumbnails from "../../defer/createThumbnails"; export function MyComp() { const { request, loading, result } = useDeferRoute(createThumbnails); return ( <div> <span>Loading: {loading ? "Yes" : "No"}</span> <span>Result: {result ? JSON.stringify(result) : "--"}</span> <button onClick={() => request("")}>Call</button> </div> ); }