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

Reliable ordering of fetch event handlers #613

Closed
wibblymat opened this issue Feb 2, 2015 · 1 comment
Closed

Reliable ordering of fetch event handlers #613

wibblymat opened this issue Feb 2, 2015 · 1 comment

Comments

@wibblymat
Copy link
Contributor

As currently implemented in Chrome, it seems that fetch handlers are called in the order that they are declared, until one calls event.respondWith. However, this isn't speced as best as I can tell.

It would be nice to add wording that says that this behavior is required so that you can, for e.g., have different parts of your application create their own fetch handlers and then add a fallback handler at the end.

self.addEventListener('fetch', function(event) {
  if (/\/myapp\/subAppA/.test(event.request.url)) {
    event.respondWith(...);
  }
});

self.addEventListener('fetch', function(event) {
  if (/\/myapp\/subAppB/.test(event.request.url)) {
    event.respondWith(...);
  }
});

self.addEventListener('fetch', function(event) {
  event.respondWith(new Response('Not found', {status: 404}));
});

As I understand it, without such spec wording a UA is free to call handlers in any order.

@annevk
Copy link
Member

annevk commented Feb 2, 2015

This simply builds on the event model which is defined: https://dom.spec.whatwg.org/

@annevk annevk closed this as completed Feb 2, 2015
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

No branches or pull requests

2 participants