-
-
Save anonymous/c37fc41804a61b361555 to your computer and use it in GitHub Desktop.
This file contains 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
[ 'create', | |
'add', | |
'add', | |
'before', | |
'go', | |
'before', | |
'done', | |
'after', | |
'after' ] | |
ok |
This file contains 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
var common = require('../common'); | |
var EventEmitter = require('events').EventEmitter; | |
var assert = require('assert'); | |
var handler_log = []; | |
var handlers = { | |
create: function () { | |
handler_log.push('create'); | |
}, | |
before: function () { | |
handler_log.push('before'); | |
}, | |
after: function () { | |
handler_log.push('after'); | |
}, | |
error: function () { | |
handler_log.push('error'); | |
}, | |
add: function () { | |
handler_log.push('add'); | |
}, | |
remove: function () { | |
handler_log.push('remove'); | |
} | |
}; | |
var observer = EventEmitter.addObserver(handlers); | |
var ee = new EventEmitter(); | |
EventEmitter.removeObserver(observer); | |
ee.on('done', function () { | |
// this event should run without observers | |
handler_log.push('done'); | |
}); | |
ee.on('go', function () { | |
handler_log.push('go'); | |
ee.emit('done'); | |
}); | |
ee.emit('go'); | |
console.log(handler_log); | |
console.log('ok'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment