Target

Buildpack/BuildBus

Buildpack/BuildBus~Target ⇐ Trackable

Represents an edge on the graph, or a “route” between stops, created between two extensions when one of them references the target(s) of another. When extension Foo requests targets of extension Bar, the BuildBus provides an Target instead of the literal Tapable instance. This enables better logging, error checking, and validation.

Kind: inner class of Buildpack/BuildBus
Extends: Trackable
See: Tapable docs

target.call([…args]) ⇒ \*

Run .call(...args) on the underlying Tapable Hook. Calls interceptors synchronously and in subscription order with the provided arguments. Returns the final value if it’s a Waterfall target, or the value returned by the first interceptor that returns a value if it’s a Bail target.

Kind: instance method of Target
Returns: \* - Returns whatever the underlying Tapable Hook returns.

Param Type Description
[…args] \* All arguments are passed to the interceptor functions that have tapped this Target.

target.callAsync(…args) ⇒ undefined

Run .callAsync(...args) on the underlying Tapable Hook. Calls interceptors asynchronously with the provided arguments. Depending on the Target type, calls interceptors in parallel or in subscription order. Last argument must be a callback. It will be invoked when all interceptors have run, or when the first returning interceptor has run if it’s a Bail target.

Kind: instance method of Target
Returns: undefined - callAsync returns nothing, instead passing any output of the interceptors as the first argument of the callback.

Param Type Description
…args \* All arguments except the last argument are passed to the interceptor functions that have tapped this Target. The last argument must be a callback function, which will receive the final output of the interceptors.

target.intercept(options) ⇒ void

Run .intercept(options) on the underlying Tapable Hook. Can register meta-interceptors for other activity on this target. Use only for logging and debugging.

Kind: instance method of Target

Param Type Description
options object Options for Tapable#intercept.

target.promise([…args]) ⇒ Promise

Run .promise(...args) on the underlying Tapable hook. Calls interceptors asynchronously with the provided arguments. Depending on the Target type, calls interceptors in parallel or in series. Returns a promise. It will be fulfilled when all interceptors have run, or when the first returning interceptor has run if it’s a Bail target.

Kind: instance method of Target
Returns: Promise - A Promise for any output of the target’s interceptors.

Param Type Description
[…args] \* All arguments are passed to the interceptor functions that have tapped this Target.

target.tap([name], interceptor) ⇒ undefined

Adds a synchronous interceptor to the target. If you just supply a function, it will use your extension’s package name as the name of the tap.

Kind: instance method of Target

Param Type Description
[name] string | object string or object containing the name of the interceptor (optional)
interceptor function interceptor function

target.tapAsync(name, interceptor) ⇒ undefined

Adds a callback-style asynchronous interceptor to the Target. The interceptor will receive a callback function as its last argument. Only supported on Async targets.

Kind: instance method of Target

Param Type Description
name string | object string or object containing the name of the interceptor
interceptor function interceptor function

target.tapPromise(name, interceptor) ⇒ undefined

Adds a Promise-returning async interceptor to the Target. The interceptor may return a Promise, which the Target will resolve. Only supported on Async targets.

Kind: instance method of Target

Param Type Description
name string | object string or object containing the name of the interceptor
interceptor function interceptor function

target.toJSON() ⇒ object

Provides the JSON object representation of this target

Kind: instance method of Target
Returns: object - JSON object

For implementation details View Source.