Skip to content

globalBeforeChangeHook

globalBeforeChangeHook<TGlobalSlug, TDataModel>(slug, fn): (<TDataModel>(props) => DocumentByGlobalSlug<TGlobalSlug> | Promise<DocumentByGlobalSlug<TGlobalSlug>>) | undefined

Defined in: packages/core/src/globals/hooks.ts:70

Types a global’s beforeChange hook against a real global and DataModel. Mirrors beforeChangeHook (collections/hooks.ts).

TGlobalSlug extends string

TDataModel extends GenericDataModel = GenericDataModel

TGlobalSlug

The global slug constant (e.g. GLOBAL_SLUG_SITE_SETTINGS).

(props) => DocumentByGlobalSlug<TGlobalSlug> | Promise<DocumentByGlobalSlug<TGlobalSlug>>

The hook function, checked against the real types.

(<TDataModel>(props) => DocumentByGlobalSlug<TGlobalSlug> | Promise<DocumentByGlobalSlug<TGlobalSlug>>) | undefined

The same function, re-typed to the global’s hooks.beforeChange signature.