Skip to content
Myr

Request#trigger() now supports callback as 2nd or 3rd arg

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent 55d13a6 · Browse files · 2 files+9 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−4 removed

  • other:+9 added−4 removed

2 files+9 added−4 removed

modified:lib/express/core.js+1 added-1 removed
263 unmodified lines
264 265 route: function(request, response){266 var self = this,267 request = new Request(request, response) 268 request.trigger('request', null, function(e) {268 request.trigger('request', function(e) {269 try {270 if (e) throw e271 if (request.response.finished) return272 if (typeof (body = (new Router(request)).route()) === 'string')
62 unmodified lines
modified:lib/express/request.js+8 added-3 removed
166 unmodified lines
167 168 respond: function(body, encoding, callback) {169 var self = this170 this.response.body = body171 this.trigger('response', null, function(e) {171 this.trigger('response', function(e) {172 if (e)173 if (callback !== undefined) callback(e)174 else throw e175 self.response.writeHeader(self.response.status, self.response.headers)
16 unmodified lines
192 return this193 },194 195 /**196 * Trigger event _name_ with optional _data_.196 * Trigger event _name_ with optional _data_ and _callback_ function.197 * The _callback_ function may be the second or third argument.198 *199 * @param {string} name199 * @param {hash} data200 * @param {object} data201 * @param {function} callback202 * @return {Request}203 * @api public204 */205206 trigger: function(name, data, callback) {207 if (data instanceof Function)208 callback = data,209 date = null210 data = data || {}211 data.merge({ request: this, response: this.response })212 var self = this,213 complete = 0,
58 unmodified lines