Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

bloody-events

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bloody-events

events in node and the browser

latest
npmnpm
Version
1.3.0
Version published
Maintainers
1
Created
Source

events

Build Status

browser support

install

$ npm install bloody-events

require

var events = require("bloody-events")

API

.create() -> events

Creates an event object

.extend(object) -> events subclass

Creates an event-object subclass

.on(type, listener[, once])

Listens to the type event with listener as callback. once defines whether or not the listener should remove itself afterwards.

listener

A listener can either be a function or an object containing a handleEvent interface.

events.on("user:log", function(username){
  model.set({
    username : username
  })
})

// or

var model = model
  .extend({
    getDefaults : function(){
      return {
        username : ""
      }
    },
    handleEvent : function(username){
      this.set({
        username : username
      })
    }
  })
  .create()
events.on("user:log", model)

// or

var model = model
  .extend({
    getDefaults : function(){
      return {
        username : "",
        isThere : true
      }
    },
    handleEvent : {
      "user:log" : function(username){
        this.set({
          username : username
        })
      },
      "user:leave" : function(){
        this.set({
          isThere : false
        })
      }
    }
  })
  .create()

events.on("user:log", model)

chainable, returns this

.once(type, listener)

Shortcut for .listen(type, listener, true)

chainable, returns this

.off([type [,listener]])

If type and listener are passed, removes the given listener. If only type is passed, removes all this type's listeners. Otherwise, removes all the events listeners.

chainable, returns this

.emit(type[, args …])

Triggers synchronously the type events, and passes args… as arguments for the listeners.

returns true if any callback has been executed returns false otherwise

subclass note

  • call events.constructor.call(this) in your constructor
  • call events.destructor.call(this) in your destructor

Keywords

events

FAQs

Package last updated on 26 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts