@@ -69,10 +69,14 @@ assumed.
6969
7070Examples:
7171``` javascript
72- composer .action (' hello' )
72+ composer .action (' hello' ) // default package
7373composer .action (' myPackage/myAction' )
7474composer .action (' /whisk.system/utils/echo' )
7575```
76+ To be clear, if no package is specified, the default package is assumed even if
77+ the composition itself is not deployed to the default package. To invoke an
78+ action from the same package as the composition the [ ` dynamic ` ] ( #dynamic )
79+ combinator may be used as illustrated [ below] ( #example ) .
7680
7781### Action definition
7882
@@ -532,3 +536,29 @@ Other fields of the input parameter object are ignored.
532536The ` dynamic ` combinator invokes the action named _ name_ with the input
533537parameter object _ params_ . The output parameter object for the composition is
534538the output parameter object of the action invocation.
539+
540+ ### Example
541+
542+ The ` dynamic ` combinator may be used for example to invoke an action that
543+ belongs to the same package as the composition, without having to specify the
544+ package name beforehand.
545+
546+ ``` javascript
547+ const composer = require (' openwhisk-composer' )
548+
549+ function invoke (actionShortName ) {
550+ return composer .let (
551+ { actionShortName },
552+ params => ({ type: ' action' , params, name: process .env .__OW_ACTION_NAME .split (' /' ).slice (0 , - 1 ).concat (actionShortName).join (' /' ) }),
553+ composer .dynamic ())
554+ }
555+
556+ module .exports = composer .seq (
557+ composer .action (' echo' ), // echo action from the default package
558+ invoke (' echo' ) // echo action from the same package as the composition
559+ )
560+ ```
561+ In this example, ` let ` captures the target action short name at compile time
562+ without expanding it to a fully qualified name. Then, at run time, the package
563+ name is obtained from the environment variable ` __OW_ACTION_NAME ` and combined
564+ with the action short name. Finally, ` dynamic ` is used to invoke the action.
0 commit comments