1.0.3 • Published 3 years ago

yaeti v1.0.3

Weekly downloads
1,515,508
License
MIT
Repository
github
Last release
3 years ago

yaeti

Yet Another EventTarget Implementation.

The library exposes both the EventTarget interface and the Event interface.

Installation

$ npm install yaeti --save

Usage

var yaeti = require('yaeti');

// Custom class we want to make an EventTarget.
function Foo() {
    // Call EventTarget constructor
    yaeti.EventTarget.call(this);
}
// Inherit EventTarget prototype
Foo.prototype = Object.create(yaeti.EventTarget.prototype);
Foo.prototype.constructor = Foo;

// Create an instance.
var foo = new Foo();

function listener1() {
    console.log('listener1');
}

function listener2() {
    console.log('listener2');
}
 
foo.addEventListener('bar', listener1);
foo.addEventListener('bar', listener2);
foo.removeEventListener('bar', listener1);

var event = new yaeti.Event('bar');

foo.dispatchEvent(event);

// Output:
// => "listener2"

API

yaeti.EventTarget interface

Implementation of the EventTarget interface.

ES5

function Foo() {
    yaeti.EventTarget.call(this);
}
Foo.prototype = Object.create(yaeti.EventTarget.prototype);
Foo.prototype.constructor = Foo;

ES6

class Foo extends EventTarget () {
    constructor () {
        super();
    }
}

The interface implements the addEventListener, removeEventListener and dispatchEvent methods as defined by the W3C.

listeners read-only property

Returns an object whose keys are configured event types (String) and whose values are an array of listeners (functions) for those event types.

yaeti.Event interface

Implementation of the Event interface.

NOTE: Just useful in Node (the browser already exposes the native Event interface).

var event = new yaeti.Event('bar');

Author

Iñaki Baz Castillo

License

MIT

websocket@energyweb/migrationscordova-plugin-iosrtc-simplyrtc@demivan/lib-jitsi-meet@everything-registry/sub-chunk-3195websocketwrapperlib-jitsi-meet-custlib-jitsi-meet-topicaloading-animatedkafirchain-tetrisgy-cordova-plugin-iosrtcmoomoopixiu-swap-corepixiuswap-libs-sdknode-red-contrib-snap4city-usernode-red-contrib-snap4city-d3-dashboard-widgetsquadratic-sdkqudratic-ui@afria/afria-libraries@chakra-swap/core@chainsafe/websocket@bonsaiswap-lib/lib@bonsaiswapv3/core@bonsaiswapv3/deploy@daostack/subgraph@daostack/subgraph-experimental@daostack/subgraph-test-env@daostack/test-env-experimentalzhuhyu-websocketzona-xwebsocket-in-nodewebsocket-patchfixwebsocket-mockupwebsocket-without-native@eliteswap/v2-core@evan.network/dbcp@innoswap/core@infinitebrahmanuniverse/nolb-yae@litedexdev/litedex-core-swap@materia-dex/materia-contracts-proxy@nirin100/quadratic-protocol@nirin100/quadratic-sdk@nodeberry/solidity-payment-processor@nomiclabs/websocket@energyweb/migrations-irec@energyweb/user-registry@energyweb/erc-test-contracts@fairwords/websocket@kodinghandle/bullswap-lib@igniswap/igni-swap-lib@olympfin/olymp-swap-lib@p2pmoney-org/ethereum_core@sudophunk/fulido@dorgtech/subgraph-experimental@dorgtech/test-env-experimental@borealisswap/borealis-swap-lib@thismr/bitmindtest-core@xswap/v2-core@yak-spirit/yak-swap-ui@web3-js/websocketcordova-plugin-iosrtccordova-plugin-iosrtc-capacitorcordova-plugin-iosrtc-extendedcordova-plugin-iosrtc-forkcordova-plugin-iosrtc-xjpcordova-plugin-tspdate-to-block-ethdynamics-contracts-xbif-websocketbidwrangler-iosrtcasync-event-targetcemento-paidcotrader-dex-sdkcssesc-wbgexasol-websocket-apiew-user-registry-contractsew-user-registry-libew-origin-lib-sonnenenefti-galeriew-erc-test-contractsew-market-contractsew-market-contracts-sonnengassefalsgassefals-2
1.0.3

3 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago