From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/serviceworker/state/index.html | 73 +++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 files/ja/web/api/serviceworker/state/index.html (limited to 'files/ja/web/api/serviceworker/state/index.html') diff --git a/files/ja/web/api/serviceworker/state/index.html b/files/ja/web/api/serviceworker/state/index.html new file mode 100644 index 0000000000..958fc15761 --- /dev/null +++ b/files/ja/web/api/serviceworker/state/index.html @@ -0,0 +1,73 @@ +--- +title: ServiceWorker.state +slug: Web/API/ServiceWorker/state +tags: + - API + - Property + - Reference + - Référence(2) + - Service Workers + - ServiceWorker + - state +translation_of: Web/API/ServiceWorker/state +--- +
{{SeeCompatTable}}{{APIRef("Service Workers API")}}
+ +

ServiceWorker インターフェイスの読み込みプロパティである state は service workerの現在の状態を表す文字列を返します。それは次のいずれかです: installing, installed, activating, activated, redundant

+ +

構文

+ +
someURL = ServiceWorker.state
+
+ +

+ +

{{domxref("ServiceWorkerState")}} 定義 (仕様を見てください)

+ +

+ +

このコードスニペットはservice worker registration-events sample (live demo)から持ってきています。コードは {{domxref("ServiceWorker.state")}} のあらゆる変更をリッスンしてその値を返します。

+ +
var serviceWorker;
+if (registration.installing) {
+  serviceWorker = registration.installing;
+  document.querySelector('#kind').textContent = 'installing';
+} else if (registration.waiting) {
+  serviceWorker = registration.waiting;
+  document.querySelector('#kind').textContent = 'waiting';
+} else if (registration.active) {
+  serviceWorker = registration.active;
+  document.querySelector('#kind').textContent = 'active';
+}
+
+if (serviceWorker) {
+  logState(serviceWorker.state);
+  serviceWorker.addEventListener('statechange', function(e) {
+  logState(e.target.state);
+  });
+}
+ +

仕様

+ + + + + + + + + + + + + + +
仕様書策定状況コメント
{{SpecName('Service Workers', '#service-worker-state-attribute', 'state')}}{{Spec2('Service Workers')}}初期定義
+ +

ブラウザー実装状況

+ +
+ + +

{{Compat("api.ServiceWorker.state")}}

+
-- cgit v1.2.3-54-g00ecf