本文整理汇总了TypeScript中events.on函数的典型用法代码示例。如果您正苦于以下问题:TypeScript on函数的具体用法?TypeScript on怎么用?TypeScript on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了on函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: test
test('it restores saved highlights', done => {
const eventBus = new EventEmitter();
const savedDecorations = [{
pattern: {
type: 'string',
expression: 'PHRASE',
ignoreCase: false,
wholeMatch: false
},
color: '#F7E4B3'
}];
const configStore = mockType<ConfigStore>({savedHighlights: savedDecorations});
const decorationOperator = mock(DecorationOperator);
const decorationOperatorFactory = mock(DecorationOperatorFactory);
when(decorationOperatorFactory.createForVisibleEditors()).thenReturn(decorationOperator);
new SavedHighlightsRestorer(configStore, decorationOperatorFactory, matchingModeRegistry, eventBus);
eventBus.on(Event.EXTENSION_READY, () => {
verify(decorationOperator.addDecoration(new StringPattern({
phrase: 'PHRASE',
ignoreCase: false,
wholeMatch: false
}), '#F7E4B3'));
done();
});
eventBus.emit(Event.EXTENSION_READY);
});
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:28,代码来源:saved-highlights-restorer.test.ts
示例2: test
test('it updates button appearance on receving case sensitivity mode change', done => {
const eventBus = new EventEmitter();
const statusBarItem = mockMethods<StatusBarItem>(['show']);
new ToggleCaseSensitivityModeButton(eventBus, statusBarItem);
eventBus.on(Event.TOGGLED_CASE_SENSITIVITY, () => {
assert.deepEqual(statusBarItem.text, 'Aa');
assert.deepEqual(statusBarItem.tooltip, 'TextMarker: Case Insensitive Mode');
verify(statusBarItem.show(), {times: 0});
done();
});
eventBus.emit(Event.TOGGLED_CASE_SENSITIVITY, {ignoreCase: true});
});
开发者ID:ryu1kn,项目名称:vscode-text-marker,代码行数:13,代码来源:toggle-case-sensitivity-mode.test.ts
示例3: Promise
return new Promise( resolve => {
// if the lock is free, lock it immediately
if (!this.locked){
this.locked = true;
// console.log('lock acquired');
return resolve();
}
// otherwise sleep the thread and register a callback for when the lock is released
let reacquire = () => {
if (!this.locked){
this.locked = true;
// console.log('lock acquired');
this.ee.removeListener('release', reacquire);
return resolve();
}
};
this.ee.on('release', reacquire);
});
开发者ID:BelaPlatform,项目名称:Bela,代码行数:18,代码来源:Lock.ts
示例4: function
node.on = function (event, action) {
nodeListener.on(event, action);
};
开发者ID:markrey,项目名称:node-red-contrib-oracledb,代码行数:3,代码来源:oracledb.spec.ts
示例5: switch
handler.on('status', event => {
const state = event.state;
switch (state) {
case 'error':
case 'failure':
const commit = event.commit;
const parent = commit.parents[0];
// Fetch parent status
request({
url: `${parent.url}/statuses`,
headers: {
'User-Agent': 'misskey'
}
}, (err, res, body) => {
if (err) {
console.error(err);
return;
}
const parentStatuses = JSON.parse(body);
const parentState = parentStatuses[0].state;
const stillFailed = parentState == 'failure' || parentState == 'error';
if (stillFailed) {
post(`**â ď¸BUILD STILL FAILEDâ ď¸**: ?[${commit.commit.message}](${commit.html_url})`);
} else {
post(`**đ¨BUILD FAILEDđ¨**: âââ?[${commit.commit.message}](${commit.html_url})âââ`);
}
});
break;
}
});
开发者ID:ha-dai,项目名称:Misskey,代码行数:31,代码来源:github.ts
注:本文中的events.on函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论