當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript events.EventEmitter類代碼示例

本文整理匯總了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;未經允許,請勿轉載。