addCallback(callbackKey, callbackFn)
Adds a callback function to CommandBar. The callback function provided is mapped to callbackKey
, and can be attached to actions by referencing callbackKey
in a command config.
See this doc that talks about how callback actions work.
Example
window.CommandBar.addCallback(
"sayHi",
// Assumes an argument called "name"
(args, context) => alert(`Hi there, ${args.name}!`)
);
Method parameters
callbackKey Required
string
Key to reference the provided function
callbackFn Required
function
Callback function, with the following signature:
Args | Type | Description |
---|---|---|
args | object | A dictionary of argument keys and the values entered by the user |
context | object | A dictionary reflecting the state of context when the callback was triggered by a command execution |