github lukeed/worktop v0.2.0

latest releases: v0.8.0-next.18, v0.8.0-next.16, v0.8.0-next.17...
3 years ago

Breaking

Important: For a complete rundown of all breaking changes, including points not mentioned in this section, please see #10

The base Router class no longer has an implicit dependency on the worktop/cache module. By disassociating, developers can now choose whether or not their application(s) should interact with the Cache, allowing worktop to now be used as a framework for authoring Service Workers – yes, for the browser!

Note: There will eventually be a worktop/sw module that provides Service Worker utilities. Other modules must come first, though.

In worktop@0.1.0, the default behavior was to pass all incoming FetchEvents through worktop/cache in search of a matching cache entry. To regain this behavior, please make the following changes after upgrading to worktop@0.2.0:

import { Router } from 'worktop';
++ import { reply } from 'worktop/cache';

const API = new Router();
// ... routes

-- addEventListener('fetch', API.listen);
++ addEventListener('fetch', reply(API.run));

Or, you may choose to involve the new listen utility, which invokes the addEventListener call for you:

import { Router } from 'worktop';
++ import * as Cache from 'worktop/cache';

const API = new Router();
// ... routes

-- addEventListener('fetch', API.listen);
++ Cache.listen(API.run);

Features

Patches

Chores

  • (bin) Prettify build table summary (#13): 87bcf51
  • (readme) Allow responsive readme logo: fd842c2

Don't miss a new worktop release

NewReleases is sending notifications on new releases.