Code Monkey home page Code Monkey logo

emitter's Introduction

emitter

Simple sync/async emitter

Why?

This differs from the built-in events emitter because:

  • quick and simple - only one data item passed with message
  • no special-case logic for error
  • can have async emits, allowing the emitter to await the processing

It's only for me. Don't use it.

API

Emitter

Subclass from this, or create a new one

.on(event, handler)

Adds a handler for the event type. Returns a function to remove.

.off(event, handler)

Removes the handler for this event type.

.once(event)

Returns a promise which resolves the first time this event is called

.emit(event, data)

Emits the event to all handlers, which are run synchronously.

.emitAsync(event, data)

Emits the event to all handlers, resolving when they have all completed.

Finally

That's it. It's simple. Don't use it.

emitter's People

Contributors

ludlovian avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.