本文整理匯總了TypeScript中@phosphor/commands.CommandRegistry.notifyCommandChanged方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CommandRegistry.notifyCommandChanged方法的具體用法?TypeScript CommandRegistry.notifyCommandChanged怎麽用?TypeScript CommandRegistry.notifyCommandChanged使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@phosphor/commands.CommandRegistry
的用法示例。
在下文中一共展示了CommandRegistry.notifyCommandChanged方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should update the node content on command change event', async () => {
const id = 'to-be-removed';
let iconClassValue: string | null = null;
const cmd = commands.addCommand(id, {
execute: () => {
/* no op */
},
label: 'Label-only button',
iconClass: () => iconClassValue
});
const button = new CommandToolbarButton({
commands,
id
});
await render(button);
const buttonNode = button.node.firstChild as HTMLButtonElement;
expect(buttonNode.textContent).to.equal('Label-only button');
expect(buttonNode.classList.contains(iconClassValue)).to.equal(false);
iconClassValue = 'updated-icon-class';
commands.notifyCommandChanged(id);
await render(button);
const wrapperNode = buttonNode.firstChild as HTMLElement;
const iconNode = wrapperNode.firstChild as HTMLElement;
expect(iconNode.classList.contains(iconClassValue)).to.equal(true);
cmd.dispose();
});
示例2: it
it('should be emitted when a command is changed', () => {
let called = false;
registry.addCommand('test', NULL_COMMAND);
registry.commandChanged.connect((reg, args) => {
expect(reg).to.equal(registry);
expect(args.id).to.equal('test');
expect(args.type).to.equal('changed');
called = true;
});
registry.notifyCommandChanged('test');
expect(called).to.equal(true);
});
示例3: NotebookSearchProvider
execute: () => {
if (searchInstance) {
searchInstance.focusInput();
return;
}
const provider = new NotebookSearchProvider();
searchInstance = new SearchInstance(nbWidget, provider);
searchInstance.disposed.connect(() => {
searchInstance = undefined;
// find next and previous are now not enabled
commands.notifyCommandChanged();
});
// find next and previous are now enabled
commands.notifyCommandChanged();
searchInstance.focusInput();
}
示例4: expect
expect(() => {
registry.notifyCommandChanged('foo');
}).to.throw(Error);
示例5:
tracker.currentChanged.connect(() => {
if (tracker.size <= 1) {
commands.notifyCommandChanged(CommandIDs.zoomIn);
}
});
示例6:
searchInstance.disposed.connect(() => {
searchInstance = undefined;
// find next and previous are now not enabled
commands.notifyCommandChanged();
});