- From: Domenic Denicola <notifications@github.com>
- Date: Tue, 20 Jan 2015 07:47:18 -0800
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
- Message-ID: <slightlyoff/ServiceWorker/issues/606/70674875@github.com>
Is it side-effecting from the author perspective, or only from the implementation perspective? On Jan 20, 2015, at 09:36, Tsuyoshi Horo <notifications@github.com<mailto:notifications@github.com>> wrote: When the ServiceWorker responds to the FetchEvent with a cached response, ServiceWorker don't need to know the body content of the response object. In such case, we don't want to send the content to the ServiceWorker. For optimization, we want to send the content only when the ServiceWorker script accesses to the content. self.addEventListener('fetch', function(event) { event.respondWith( cache.match('http://example.com/file/') .then(function(response) { return response; })); }); Response.body provides a way to access to the content. So we want to send the content when Response.body is accessed. This means Response.body is a side-effecting attribute. I think side-effecting attributes are not good. For example, console.log(response); may cause unexpected behaviour. So I want Response.body to be a method. Furthermore, if Response.body is a method, comparing two response objects in tests become easier. We are currently using custom assert_object_equals()<https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/override_assert_object_equals.js> in tests not to access to Response.body attribute while comparing two response objects. - Reply to this email directly or view it on GitHub<https://github.com/slightlyoff/ServiceWorker/issues/606>. --- Reply to this email directly or view it on GitHub: https://github.com/slightlyoff/ServiceWorker/issues/606#issuecomment-70674875
Received on Tuesday, 20 January 2015 15:47:45 UTC