use .storeName during tracing (#560)
This commit is contained in:
@@ -414,7 +414,11 @@ Initialize a new `choo` instance. `opts` can also contain the following values:
|
|||||||
Call a function and pass it a `state` and `emitter`. `emitter` is an instance
|
Call a function and pass it a `state` and `emitter`. `emitter` is an instance
|
||||||
of [nanobus](https://github.com/choojs/nanobus/). You can listen to
|
of [nanobus](https://github.com/choojs/nanobus/). You can listen to
|
||||||
messages by calling `emitter.on()` and emit messages by calling
|
messages by calling `emitter.on()` and emit messages by calling
|
||||||
`emitter.emit()`.
|
`emitter.emit()`. Callbacks passed to `app.use()` are commonly referred to as
|
||||||
|
`'stores'`.
|
||||||
|
|
||||||
|
If the callback has a `.storeName` property on it, it will be used to identify
|
||||||
|
the callback during tracing.
|
||||||
|
|
||||||
See [#events](#events) for an overview of all events.
|
See [#events](#events) for an overview of all events.
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ Choo.prototype.route = function (route, handler) {
|
|||||||
|
|
||||||
Choo.prototype.use = function (cb) {
|
Choo.prototype.use = function (cb) {
|
||||||
assert.equal(typeof cb, 'function', 'choo.use: cb should be type function')
|
assert.equal(typeof cb, 'function', 'choo.use: cb should be type function')
|
||||||
var endTiming = nanotiming('choo.use')
|
var msg = 'choo.use'
|
||||||
|
msg = cb.storeName ? msg + '(' + cb.storeName + ')' : msg
|
||||||
|
var endTiming = nanotiming(msg)
|
||||||
cb(this.state, this.emitter, this)
|
cb(this.state, this.emitter, this)
|
||||||
endTiming()
|
endTiming()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user