Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a single fetch handler per Router #382

Merged
merged 3 commits into from
Mar 25, 2017

Conversation

jeffposnick
Copy link
Contributor

R: @addyosmani @gauntface

The diff is pretty busy, but this is basically just shifting the fetch handler into the Router constructor, and storing the list of routes in a private member variable.

Fixes #354

@addyosmani addyosmani self-assigned this Mar 24, 2017
Copy link

@gauntface gauntface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good - only comment is regarding an optimization using the route methods.

@@ -122,7 +71,7 @@ class Router {

let responsePromise;
let matchingRoute;
for (let route of (routes || [])) {
for (let route of this._routes) {
if (route.method !== event.request.method) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we drop support for 'all' like sw-toolbox had?

If so, should we group routes together by method - reducing this loop for each request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we don't have support for all. I can switch to keeping track of routes per-method to optimize the loop.

@jeffposnick
Copy link
Contributor Author

PTAL at the revised approach to confirm you're still 👍

@jeffposnick jeffposnick merged commit 7811957 into master Mar 25, 2017
@jeffposnick jeffposnick deleted the router-fetch-handler-refactor branch March 25, 2017 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants