Last active
December 17, 2015 03:29
-
-
Save e-jigsaw/5543962 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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