diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
commit | da78a9e329e272dedb2400b79a3bdeebff387d47 (patch) | |
tree | e6ef8aa7c43556f55ddfe031a01cf0a8fa271bfe /files/ko/web/api/clients | |
parent | 1109132f09d75da9a28b649c7677bb6ce07c40c0 (diff) | |
download | translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.gz translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.bz2 translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.zip |
initial commit
Diffstat (limited to 'files/ko/web/api/clients')
-rw-r--r-- | files/ko/web/api/clients/claim/index.html | 66 | ||||
-rw-r--r-- | files/ko/web/api/clients/index.html | 102 |
2 files changed, 168 insertions, 0 deletions
diff --git a/files/ko/web/api/clients/claim/index.html b/files/ko/web/api/clients/claim/index.html new file mode 100644 index 0000000000..ff74825a1d --- /dev/null +++ b/files/ko/web/api/clients/claim/index.html @@ -0,0 +1,66 @@ +--- +title: Clients.claim() +slug: Web/API/Clients/claim +translation_of: Web/API/Clients/claim +--- +<p>{{SeeCompatTable}}{{APIRef("Service Worker Clients")}}</p> + +<p><span class="seoSummary">{{domxref("Clients")}} 의 <strong><code>claim()</code></strong> 메소드는 active 서비스워커가 그것의 {{domxref("ServiceWorkerRegistration.scope", "scope")}} 를 가지는 모든 클라이언트들의 {{domxref("ServiceWorkerContainer.controller", "controller")}} 로서 자신을 등록하는 것을 허용한다. 이것은 이 서비스워커가 제어하게 될 클라이언트들에 "<code>controllerchange</code>" 이벤트를 발생시킨다.</span></p> + +<p>서비스워커가 최초에 등록되면, 페이지들은 다음 로드시까지 그것을 사용하지 않을 것이다. <code>claim()</code> 메소드는 그 페이지들을 즉시 제어될 수 있도록 한다. 이로 인해, 당신의 서비스워커는 네트워크 또는 다른 서비스워커를 통해 정기적으로 로드되는 페이지들을 제어하게 된다.</p> + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox">await clients.claim(); +</pre> + +<h3 id="Parameters">Parameters</h3> + +<p>None.</p> + +<h3 id="Returns">Returns</h3> + +<p>A {{jsxref("Promise")}} for <code>void</code>.</p> + +<h2 id="Example">Example</h2> + +<p>다음 예시는 서비스워커의 "<code>activate</code>" 이벤트 리스너에서 <code>claim()</code> 를 사용하므로, fetch 들이 이 서비스워커를 통과하기 전에 동일한 스코프에서 로드된 클라이언트들은 다시 로드될 필요가 없다. .</p> + +<pre class="brush: js">self.addEventListener('activate', event => { + event.waitUntil(clients.claim()); +});</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', '#clients-claim', 'claim()')}}</td> + <td>{{Spec2('Service Workers')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<div> + + +<p>{{Compat("api.Clients.claim")}}</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://developers.google.com/web/fundamentals/instant-and-offline/service-worker/lifecycle">The service worker lifecycle</a></li> + <li><a href="https://jakearchibald.github.io/isserviceworkerready/">Is ServiceWorker ready?</a></li> + <li>{{jsxref("Promise", "Promises")}}</li> + <li>{{domxref("ServiceWorkerGlobalScope.skipWaiting()", "self.skipWaiting()")}} - skip the service worker's waiting phase </li> +</ul> diff --git a/files/ko/web/api/clients/index.html b/files/ko/web/api/clients/index.html new file mode 100644 index 0000000000..d4365b320e --- /dev/null +++ b/files/ko/web/api/clients/index.html @@ -0,0 +1,102 @@ +--- +title: Clients +slug: Web/API/Clients +tags: + - API + - Clients + - Experimental + - Interface + - NeedsTranslation + - Reference + - Service Workers + - Service worker API + - ServiceWorker + - TopicStub + - Workers +translation_of: Web/API/Clients +--- +<p>{{SeeCompatTable}}{{APIRef("Service Workers API")}}</p> + +<p><span class="seoSummary">The <code>Clients</code> interface provides access to {{domxref("Client")}} objects. Access it via <code>{{domxref("ServiceWorkerGlobalScope", "self")}}.clients</code> within a <a href="/en-US/docs/Web/API/ServiceWorker_API">service worker</a>.</span></p> + +<h2 id="Methods">Methods</h2> + +<dl> + <dt>{{domxref("Clients.get()")}}</dt> + <dd>Returns a {{jsxref("Promise")}} for a {{domxref("Client")}} matching a given {{domxref("Client.id", "id")}}.</dd> + <dt>{{domxref("Clients.matchAll()")}}</dt> + <dd>Returns a {{jsxref("Promise")}} for an array of {{domxref("Client")}} objects. An options argument allows you to control the types of clients returned. </dd> + <dt>{{domxref("Clients.openWindow()")}}</dt> + <dd>Opens a new browser window for a given url and returns a {{jsxref("Promise")}} for the new {{domxref("WindowClient")}}.</dd> + <dt>{{domxref("Clients.claim()")}}</dt> + <dd>Allows an active service worker to set itself as the {{domxref("ServiceWorkerContainer.controller", "controller")}} for all clients within its {{domxref("ServiceWorkerRegistration.scope", "scope")}}. </dd> +</dl> + +<h2 id="Examples">Examples</h2> + +<p>The following example shows an existing chat window or creates a new one when the user clicks a notification.</p> + +<pre class="brush: js">addEventListener('notificationclick', event => { + event.waitUntil(async function() { + const allClients = await clients.matchAll({ + includeUncontrolled: true + }); + + let chatClient; + + // Let's see if we already have a chat window open: + for (const client of allClients) { + const url = new URL(client.url); + + if (url.pathname == '/chat/') { + // Excellent, let's use it! + client.focus(); + chatClient = client; + break; + } + } + + // If we didn't find an existing chat window, + // open a new one: + if (!chatClient) { + chatClient = await clients.openWindow('/chat/'); + } + + // Message the client: + chatClient.postMessage("New chat messages!"); + }()); +}); +</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', '#clients', 'Clients')}}</td> + <td>{{Spec2('Service Workers')}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<div> + + +<p>{{Compat("api.Clients")}}</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://jakearchibald.github.io/isserviceworkerready/">Is ServiceWorker ready?</a></li> + <li>{{jsxref("Promise")}}</li> +</ul> |