本文整理汇总了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, '');
});