Skip to content

Instantly share code, notes, and snippets.

@e-jigsaw
Last active December 17, 2015 03:29
Show Gist options
  • Select an option

  • Save e-jigsaw/5543962 to your computer and use it in GitHub Desktop.

Select an option

Save e-jigsaw/5543962 to your computer and use it in GitHub Desktop.
{EventEmitter} = require "events"
class Lib extends EventEmitter
constructor: (@arg1, @arg2)->
exec: =>
async.get (err, result)->
if err?
@emit "error", new Error err
else
@emit "done", result
module.exports = Lib
Lib = require "./lib"
lib = new Lib arg1, arg2
lib.on "error", (err)->
# error handling
lib.on "done", (result)->
# yay!
lib.exec()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment