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