本文整理匯總了TypeScript中tinymce/core/api/util/EventDispatcher.fire函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fire函數的具體用法?TypeScript fire怎麽用?TypeScript fire使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了fire函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
suite.test('off (all named)', function () {
const dispatcher = new EventDispatcher();
let data = '';
const listenerA = function () {
data += 'a';
};
const listenerB = function () {
data += 'b';
};
const listenerC = function () {
data += 'c';
};
dispatcher.on('click', listenerA);
dispatcher.on('click', listenerB);
dispatcher.on('keydown', listenerC);
dispatcher.off('click');
data = '';
dispatcher.fire('click');
dispatcher.fire('keydown');
LegacyUnit.equal(data, 'c');
});
示例2: setting
suite.test('beforeFire setting (stopImmediatePropagation)', function () {
let lastArgs, dispatcher, args, data = '';
dispatcher = new EventDispatcher({
beforeFire (args) {
lastArgs = args;
args.stopImmediatePropagation();
}
});
const listenerA = function () {
data += 'a';
};
dispatcher.on('click', listenerA);
args = dispatcher.fire('click');
LegacyUnit.equal(lastArgs === args, true);
LegacyUnit.equal(data, '');
});