Closed lewispham closed 9 years ago
Yeah, taste and consistency. Also, a constructor shouldn't change state outside its own object. In the case of creating a new ServiceWorker registration, that's added to an underlying registry, so the effects persist even if the registration object on the page is garbage collected.
@jakearchibald that reasoning seems flawed as we have many constructors that have side effects. E.g. new Worker()
does exactly that. And new SharedWorker()
affects a registry.
Why doesn't Service Worker use Constructor instead of the current approach? Is this a matter of taste?