From 92372b9bff604a6ffd6f5f89097cc53eb1160d35 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Tue, 3 Oct 2017 12:34:36 -0400 Subject: [PATCH] use .storeName during tracing (#560) --- README.md | 6 +++++- index.js | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d025c76..aa84781 100644 --- a/README.md +++ b/README.md @@ -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 of [nanobus](https://github.com/choojs/nanobus/). You can listen to 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. diff --git a/index.js b/index.js index b49b385..20eec08 100644 --- a/index.js +++ b/index.js @@ -77,7 +77,9 @@ Choo.prototype.route = function (route, handler) { Choo.prototype.use = function (cb) { 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) endTiming() }