Skip to content

Commit

Permalink
remove use hook (no longer working) (#7)
Browse files Browse the repository at this point in the history
- removes an outdated listener call that no longer reports accurate information due to store ordering changes in 6.x
- companion to choojs/choo-devtools#38
  • Loading branch information
ungoldman authored Mar 23, 2020
1 parent ea523c5 commit b72dc0d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ Listen for service worker event.
### `hook.on('event', cb(eventName, timing, data))`
Called for events implemented at the application layer.

### `hook.on('use', cb(count, duration))`
Called whenever `app.use()` is called.

### `hook.on('unhandled', cb(eventName, data))`
Called whenever an event is emitted, and there is no handler available.

Expand Down
18 changes: 0 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function ChooHooks (emitter) {
this.emitter = emitter
this.listeners = {}
this.buffer = {
use: [],
render: {},
events: {}
}
Expand Down Expand Up @@ -49,8 +48,6 @@ ChooHooks.prototype.start = function () {
self.buffer.render.route = timing
} else if (/choo\.render/.test(eventName)) {
self.buffer.render.render = timing
} else if (/choo\.use/.test(eventName)) {
self.buffer.use.push(timing)
} else if (/choo\.emit/.test(eventName) && !/log:/.test(eventName)) {
var eventListener = self.listeners['event']
if (eventListener) {
Expand Down Expand Up @@ -118,8 +115,6 @@ ChooHooks.prototype._emitLoaded = function () {
var self = this
scheduler.push(function clear () {
var listener = self.listeners['DOMContentLoaded']
var usesListener = self.listeners['use']

var timing = self.hasWindow && window.performance && window.performance.timing

if (listener && timing) {
Expand All @@ -128,18 +123,5 @@ ChooHooks.prototype._emitLoaded = function () {
loaded: timing.domContentLoadedEventEnd - timing.navigationStart
})
}

if (self.hasPerformance) {
var duration = sumDurations(self.buffer.use)
if (usesListener) usesListener(self.buffer.use.length, duration)
} else {
usesListener()
}
})
}

function sumDurations (timings) {
return timings.reduce(function (sum, timing) {
return sum + timing.duration
}, 0).toFixed()
}

0 comments on commit b72dc0d

Please sign in to comment.