How to use the metal-events.EventEmitter function in metal-events

To help you get started, we’ve selected a few metal-events examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metal / metal.js / test / DomEventEmitterProxy.js View on Github external
it('should change the element that events are proxied from', function() {
		var origin = document.createElement('div');
		document.body.appendChild(origin);

		var target = new EventEmitter();
		var proxy = new DomEventEmitterProxy(origin, target);

		var listener = sinon.stub();
		target.on('click', listener);

		var origin2 = document.createElement('div');
		document.body.appendChild(origin2);
		proxy.setOriginEmitter(origin2);

		dom.triggerEvent(origin, 'click');
		assert.strictEqual(0, listener.callCount);

		dom.triggerEvent(origin2, 'click');
		assert.strictEqual(1, listener.callCount);
		assert.ok(listener.args[0][0]);
github liferay / senna.js / test / app / App.js View on Github external
it('should not to clear screen cache the being used in a pending navigation', (done) => {
		const event = new EventEmitter();
		class StubScreen extends Screen {
			constructor() {
				super();

				this.cacheable = true;
			}

			flip(surfaces) {
				super.flip(surfaces);
				event.emit('flip');
			}
		}

		const callback = () => {
			this.app.clearScreensCache();
			assert.strictEqual(1, Object.keys(this.app.screens).length);
github metal / metal.js / test / DomEventEmitterProxy.js View on Github external
it('should not proxy event emitter events after disposed', function() {
		var origin = new EventEmitter();
		var target = new EventEmitter();
		var proxy = new DomEventEmitterProxy(origin, target);

		var listener = sinon.stub();
		target.on('event1', listener);

		proxy.dispose();
		origin.emit('event1', 1, 2);
		assert.strictEqual(0, listener.callCount);
	});

metal-events

Classes responsible for emitting and listening to events

BSD
Latest version published 6 years ago

Package Health Score

57 / 100
Full package analysis