How to use the eventemitter3 function in eventemitter3

To help you get started, we’ve selected a few eventemitter3 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 redibox / core / src / hooks / PubSubHook.js View on Github external
constructor() {
    super('pubsub');
    this._mountToCore = true;

    // all pubsub messages from redis are routed through this emitter
    // so we can send them to the correct handlers
    this._router = new EventEmitter();
  }
github rse / apollo-client-ws / src / apollo-client-ws.js View on Github external
reconnectattempts: number,
            reconnectdelay:    number
        }`, errors))
            throw new Error(`invalid options: ${errors.join("; ")}`)

        /*  initialize state variables  */
        this._ws   = null
        this._wsf  = null
        this._to   = null
        this._tx   = {}

        /*  provide hook latching sub-system  */
        this._latching = new Latching()

        /*  provide event emitter sub-system  */
        this._emitter  = new EventEmitter()
    }
github ChefSteps / react-native-declan / src / triggers / BaseTrigger.js View on Github external
cloneAnimator = (animator: React.Element<*>, index: number) => {
    const events = new EventEmitter();
    return React.cloneElement(animator, {
      ...(this.state.propertiesToAppend || {}),
      // eslint-disable-next-line react/no-array-index-key
      key: index,
      ref: ref => {
        this.animators[index] = {
          ref,
          events,
        };
        if (animator.ref) {
          animator.ref(ref);
        }
      },
      onFinish: ({ finished }) => {
        if (animator.props.onFinish) {
          animator.props.onFinish({ finished });
github alibaba / rax / packages / my-api-compat / src / api / websocket.js View on Github external
import WebSocket from '@core/webSocket';
import EventEmitter from 'eventemitter3';
import { callWithCallback } from '../util';

const bus = new EventEmitter();
const events = [ 'onOpen', 'onError', 'onMessage', 'onClose' ];
let instanceId = 0;
let opened = false;

export function connectSocket(options) {
  if (opened) {
    WebSocket.close({ instanceId });
    opened = false;
    instanceId++;
  }

  WebSocket.webSocket({
    instanceId: instanceId,
    url: options.url,
    protocol: ''
  }, res => {
github polkadot-js / client / packages / client-p2p / src / peers / logPeer.spec.js View on Github external
beforeEach(() => {
    state = {
      emitter: new EventEmitter(),
      l
    };
  });
github rambler-digital-solutions / rambler-ui / src / Menu / Menu.js View on Github external
createEvents() {
    this.events = new EventEmitter()
    this.events.on('onItemSelect', this.handleOptionSelect)
    this.events.on('onItemFocus', this.handleOptionFocus)
    this.events.on('onItemMount', this.addItem)
    this.events.on('onItemUnmount', this.removeItem)
  }
github ConnextProject / indra / modules / cf-core / src / node.ts View on Github external
private constructor(
    private readonly publicExtendedKey: string,
    private readonly privateKeyGetter: PrivateKeysGetter,
    private readonly messagingService: CFCoreTypes.IMessagingService,
    private readonly storeService: CFCoreTypes.IStoreService,
    private readonly nodeConfig: NodeConfig,
    private readonly provider: BaseProvider,
    public readonly networkContext: NetworkContext,
    public readonly blocksNeededForConfirmation: number = REASONABLE_NUM_BLOCKS_TO_WAIT,
    private readonly lockService?: CFCoreTypes.ILockService
  ) {
    this.networkContext.provider = this.provider;
    this.incoming = new EventEmitter();
    this.outgoing = new EventEmitter();
    this.protocolRunner = this.buildProtocolRunner();
    log.info(
      `Waiting for ${this.blocksNeededForConfirmation} block confirmations`
    );
  }
github wix / kissfs / src / utils.ts View on Github external
export function makeEventsEmitter(): InternalEventsEmitter {
    return new EventEmitter() as InternalEventsEmitter;
}
github rambler-digital-solutions / rambler-ui / src / ComplexSearch / provideSearchDropdown.js View on Github external
constructor(props) {
      super(props)

      this.state = {
        isDropdownOpened: false
      }

      this.events = new EventEmitter()

      /**
       * Упорядоченный массив с зарегестрированными компонентами SuggestItem
       * @type {Array}
       */
      this.sortedSuggestItems = []
      /**
       * Объект с сохраненными suggestItems
       */
      this.suggestItems = {}
      /**
       * Текущий подсвеченный элемент
       */
      this.highlightedSuggestItemId = null
    }
github badbatch / graphql-box / packages / websocket-manager / src / main / index.ts View on Github external
constructor(options: ConstructorOptions) {
    this._eventEmitter = new EventEmitter();
    options.websocket.onmessage = this._onMessage.bind(this);
    this._websocket = options.websocket;
  }

eventemitter3

EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface.

MIT
Latest version published 1 year ago

Package Health Score

79 / 100
Full package analysis