public createInstance(props: ICameraHelperProps) {
    let cameraToUse = props.camera;

    if (cameraToUse == null) {
      cameraToUse = defaultCamera;
    }

    const instance = new CameraHelper(cameraToUse);

    const cameraHelperUserData = instance.userData as any;

    cameraHelperUserData[cameraEventListenerSymbol] = () => {
      instance.update();
    };

    if (props.camera != null) {
      const cameraEventEmitter: EventEmitter = props.camera.userData[cameraEventsSymbol];

      cameraEventEmitter
        .addListener(cameraEventProjectionMatrixUpdated, cameraHelperUserData[cameraEventListenerSymbol]);
    }

    return instance;
  }
Example #2
0
const listener3 = (arg1: string) => {
  console.log('listener3', arg1);
};
const listener4 = () => {
  console.log('type of number');
};
const listener5 = () => {
  console.log('prepend listener');
};
const listener6 = () => {
  console.log('prepend once listener');
};

emitter.setMaxListeners(100);

emitter.addListener('send', listener1);

emitter.on('send', listener2);

emitter.on('send', listener3);

emitter.once('send', listener);

emitter.once(1, listener4);

emitter.prependListener('send', listener5);

emitter.prependOnceListener('send', listener6);

emitter.listeners('send');
emitter.listenerCount('send');
Example #3
0
import * as events from 'events';

const emitter: events.EventEmitter = new events.EventEmitter();
const event: string | symbol = '';
const listener: (...args: any[]) => void = () => {};
const any: any = 1;

{
    let result: events.EventEmitter;

    result = emitter.addListener(event, listener);
    result = emitter.on(event, listener);
    result = emitter.once(event, listener);
    result = emitter.prependListener(event, listener);
    result = emitter.prependOnceListener(event, listener);
    result = emitter.removeListener(event, listener);
    result = emitter.off(event, listener);
    result = emitter.removeAllListeners();
    result = emitter.removeAllListeners(event);
    result = emitter.setMaxListeners(42);
}

{
    let result: number;

    result = events.EventEmitter.defaultMaxListeners;
    result = events.EventEmitter.listenerCount(emitter, event); // deprecated

    const promise: Promise<any> = events.once(new events.EventEmitter(), 'error');

    result = emitter.getMaxListeners();
Example #4
0
 zoneA.run(() => {
   expect(emitter.on('test', expectZoneA)).toBe(emitter);
   expect(emitter.addListener('test', expectZoneA)).toBe(emitter);
 });
Example #5
0
 zoneA.run(() => {
   emitter.on('test', expectZoneA);
   emitter.addListener('test', expectZoneA);
 });
Example #6
0
	addListener(handler: (message: any) => void): void {
		this.emitter.addListener('message', handler);
	}
Example #7
0
 h => e.addListener(EVENT_TYPE, h),