本文整理汇总了TypeScript中events.EventEmitter类的典型用法代码示例。如果您正苦于以下问题:TypeScript EventEmitter类的具体用法?TypeScript EventEmitter怎么用?TypeScript EventEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventEmitter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('.get with invalid service name and arguments', done => {
const socket = new EventEmitter();
provider.emit('connection', socket);
socket.emit('get', null, (error: any) => {
assert.strictEqual(error.name, 'NotFound');
assert.strictEqual(error.message, `Service 'null' not found`);
done();
});
});
开发者ID:feathersjs,项目名称:feathers,代码行数:11,代码来源:index.test.ts
示例2: addHandler
function addHandler(emitter: EventEmitter, event: string, handler: (...args: Array<any>) => void) {
if (isLogEvent) {
emitter.on(event, (...args: Array<any>) => {
console.log("%s %s", event, args)
handler.apply(null, args)
})
}
else {
emitter.on(event, handler)
}
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:11,代码来源:main.ts
示例3: test
test('`waitUntilWatchIsReady` correctly handles `tsc` output', async () => {
buildOutputStream.emit('data', Buffer.from('$ tsc'));
buildOutputStream.emit('data', Buffer.from('Compilation complete.'));
jest.runAllTimers();
expect(await completionHintPromise).toBe('tsc');
});
开发者ID:Jaaess,项目名称:kibana,代码行数:8,代码来源:watch.test.ts
示例4: test
test('`waitUntilWatchIsReady` fallbacks to default output handler if output is not recognizable', async () => {
buildOutputStream.emit('data', Buffer.from('$ some-cli'));
buildOutputStream.emit('data', Buffer.from('Compilation complete.'));
buildOutputStream.emit('data', Buffer.from('Chunk Names.'));
jest.runAllTimers();
expect(await completionHintPromise).toBe('timeout');
});
开发者ID:cccnam5158,项目名称:kibana,代码行数:9,代码来源:watch.test.ts
示例5: return
return () => {
bag.dispose();
if (input) {
input.removeAllListeners();
}
if (output) {
output.removeAllListeners();
}
};
开发者ID:d6u,项目名称:dev-runner,代码行数:9,代码来源:utils.ts
示例6:
window.addEventListener("storage", (event) => {
if (event.key !== storageKey) return;
const oldPub = pub;
pub = JSON.parse(event.newValue);
if (oldPub.keyMap !== pub.keyMap) emitter.emit("keyMap");
if (oldPub.theme !== pub.theme) emitter.emit("theme");
});
开发者ID:w84miracle,项目名称:superpowers-common-plugins,代码行数:9,代码来源:textEditorUserSettings.ts
示例7: resolve
return new Promise<any>((resolve, reject) => {
emitter.once(event, (value: any) => {
resolve(value);
});
emitter.once('error', (err: Error) => {
reject(err);
});
});
开发者ID:driftyco,项目名称:ionic-cli,代码行数:9,代码来源:promise.ts
示例8: function
zoneA.run(() => {
emitter.on('removeListener', function(type: string, handler: any) {
zoneResults.push('remove' + type);
});
emitter.on('test', shouldNotRun);
emitter.on('test1', expectZoneA);
emitter.removeAllListeners('test');
expect(zoneResults).toEqual(['removetest']);
expect(emitter.listeners('removeListener').length).toBe(1);
});
开发者ID:jahtalab,项目名称:zone.js,代码行数:10,代码来源:events.spec.ts
示例9: function
response.on('end', function() {
try {
output = JSON.parse(content)
emitter.emit('done', output)
}
catch (e) {
e.cause = content
emitter.emit('error', e)
}
})
开发者ID:RemediIO,项目名称:NurseBot,代码行数:10,代码来源:athenahealthapi.ts
注:本文中的events.EventEmitter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论