Peregrine Extensibility Targets
This page lists the Targets declared in the Peregrine package.
Access these in your intercept files by calling targets.of('@magento/peregrine')
on the TargetProvider object.
/* my-custom-interceptors.js */
module.exports = targets => {
const peregrineTargets = targets.of('@magento/peregrine')
}
See the PWA Studio Target Experiments project repository for documented examples of extensions that use PWA Studio’s extensibility framework.
Members
- hooks :
tapable.AsyncSeriesHook - Provides access to Peregrine React hooks. This target collects requests to intercept and "wrap" individual Peregrine hooks in decorator functions. Use this target to run custom code whenever the application calls a Peregrine hook. You can also use this target to modify the behavior or output returned by a hook.
- talons :
tapable.AsyncSeriesHook - Provides access to Peregrine talon wrappers. This target collects requests to intercept and "wrap" individual Peregrine talons in decorator functions. Use this target to run custom code whenever the application calls a Peregrine talon. You can also use this target to modify the behavior or output returned by a talon.
Typedefs
- hookInterceptFunction :
function - Intercept function signature for the `talons` and `hooks` targets. Interceptors of `hooks` should call `wrapWith` on the individual hooks in the provided [`HookInterceptorSet` object](http://pwastudio.io/peregrine/reference/targets/wrappable-talons).
Provides access to Peregrine React hooks.
This target collects requests to intercept and “wrap” individual Peregrine hooks in decorator functions.
Use this target to run custom code whenever the application calls a Peregrine hook. You can also use this target to modify the behavior or output returned by a hook.
See: Intercept function signature
Example (Access the tapable object)
const peregrineTargets = targets.of('@magento/peregrine');
const hooksTarget = peregrineTargets.hooks;
Example (Wrap the `useAwaitQuery()` hook with a logging extension)
hooksTargets.tap( => {
hook.useAwaitQuery.wrapWith('@my-extensions/log-wrapper');
})
Provides access to Peregrine talon wrappers.
This target collects requests to intercept and “wrap” individual Peregrine talons in decorator functions.
Use this target to run custom code whenever the application calls a Peregrine talon. You can also use this target to modify the behavior or output returned by a talon.
See: Intercept function signature
Example (Access the tapable object)
const peregrineTargets = targets.of('@magento/peregrine');
const talonsTarget = peregrineTargets.talons;
Example (Wrap the `useApp()` hook with a logging extension)
talonsTarget.tap(talons => {
talons.App.useApp.wrapWith('@my-extensions/log-wrapper');
})
Intercept function signature for the talons
and hooks
targets.
Interceptors of hooks
should call wrapWith
on the individual hooks in
the provided HookInterceptorSet
object.
Parameters
Name | Type | Description |
---|---|---|
hookInterceptors | HookInterceptorSet |
Registry of wrappable hook namespaces |
Source Code: pwa-studio/packages/peregrine/lib/targets/peregrine-declare.js