Skip to main content

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:

ArgsTypeDescription
argsobjectA dictionary of argument keys and the values entered by the user
contextobjectA dictionary reflecting the state of context when the callback was triggered by a command execution