aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/serviceworkerglobalscope/skipwaiting/index.html
blob: a6c3e50e968f328e4327483e3e3e7f0668544d20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
title: ServiceWorkerGlobalScope.skipWaiting()
slug: Web/API/ServiceWorkerGlobalScope/skipWaiting
translation_of: Web/API/ServiceWorkerGlobalScope/skipWaiting
---
<div>{{APIRef("Service Workers API")}}</div>

<p><span class="seoSummary">{{domxref("ServiceWorkerGlobalScope")}} 의 <strong><code>ServiceWorkerGlobalScope.skipWaiting()</code></strong> 메소드는 waiting 상태의 서비스 워커를 active 상태의 서비스 워커로 변경하도록 강제한다.</span></p>

<p>근본적인 서비스 워커에 대한 업데이트들이 현재의 클라이언트와 다른 모든 active 클라이언트들에게 즉시 적용되도록 하기 위해 {{domxref("Clients.claim()")}} 과 이 메소드를 사용한다.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="brush: js">ServiceWorkerGlobalScope.skipWaiting().then(function() {
  //Do something
});</pre>

<h3 id="Returns">Returns</h3>

<p><code>undefined</code> 로 즉시 resolve 되는 {{jsxref("Promise")}}</p>

<h2 id="Example">Example</h2>

<p>서비스 워커가 실행되는 동안 언제라도 <code>self.skipWaiting()</code> 는 호출될 수 있지만, 이것은 <code>waiting</code> 상태로 남아 있을 수도 있는 새롭게 설치된 서비스 워커가 있는 경우에만 영향을 줄 수 있다. 따라서, {{domxref("InstallEvent")}} 핸들러 내부에서 <code>self.skipWaiting()</code> 을 호출하는 것이 일반적이다.</p>

<p>다음 예시는 active 상태의 서비스 워커가 이미 존재하는지의 여부에 관계없이, 새로 설치된 서비스 워커가  <code>activating</code> 상태로 진행되도록 한다.</p>

<pre class="brush: js">self.addEventListener('install', function(event) {
  // skipWaiting()가 반환하는 promise는 안전하게 무시될 수 있다.
  self.skipWaiting();

  // 잠재적으로 event.waitUntil(); 내부에서
  // 서비스 워커 설치를 위해 필요한 다른 action 들을 수행하라.
});
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Service Workers', '#service-worker-obj', 'ServiceWorker')}}</td>
   <td>{{Spec2('Service Workers')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>


<p>{{Compat("api.ServiceWorkerGlobalScope.skipWaiting")}}</p>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en-US/docs/Web/API/ServiceWorker_API/Using_Service_Workers">Using Service Workers</a></li>
 <li><a href="https://github.com/mdn/sw-test">Service workers basic code example</a></li>
 <li><a href="https://jakearchibald.github.io/isserviceworkerready/">Is ServiceWorker ready?</a></li>
 <li>{{domxref("Clients.claim()")}}</li>
 <li>{{jsxref("Promise", "Promises")}}</li>
 <li><a href="/en-US/docs/Web/Guide/Performance/Using_web_workers">Using web workers</a></li>
</ul>