Skip to content
This repository was archived by the owner on Dec 15, 2020. It is now read-only.

litejs/events-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@version  0.1.0
@date     2015-05-22

Event – Build Coverage

Event.Emitter can be mixed in to any object, giving the object the ability to emit named events.

Usage

Mix Event.Emitter to custom object.

function MyObj(name) {
    this.name = name
}
Object.assign(MyObj.prototype, Event.Emitter)

var obj = new MyObj("obj1")

obj.on("say", function(text) {
    console.log(this.name + " says: " + text)
})

obj.emit("say", "hello world")

Use in Mediator Pattern.

// Define global mediator

var Mediator = Object.create(Event.Emitter)

// Listen login events in login controller
Mediator.on("login", function(user, pass) {
    // login code
})

// Emit login event from login view
Mediator.emit("login", "username", "secretPassword")

External links

Licence

Copyright (c) 2013-2015 Lauri Rooden <lauri@rooden.ee>
The MIT License

About

DEPRECATED! It is merged into litejs

Resources

Contributing

Security policy

Stars

Watchers

Forks

Contributors