From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- files/ko/web/api/clients/claim/index.html | 66 +++++++++++++++++++ files/ko/web/api/clients/index.html | 102 ++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 files/ko/web/api/clients/claim/index.html create mode 100644 files/ko/web/api/clients/index.html (limited to 'files/ko/web/api/clients') 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 +--- +

{{SeeCompatTable}}{{APIRef("Service Worker Clients")}}

+ +

{{domxref("Clients")}} 의 claim() 메소드는 active 서비스워커가 그것의 {{domxref("ServiceWorkerRegistration.scope", "scope")}} 를 가지는 모든 클라이언트들의 {{domxref("ServiceWorkerContainer.controller", "controller")}} 로서 자신을 등록하는 것을 허용한다. 이것은 이 서비스워커가 제어하게 될 클라이언트들에 "controllerchange" 이벤트를 발생시킨다.

+ +

서비스워커가 최초에 등록되면, 페이지들은 다음 로드시까지 그것을 사용하지 않을 것이다. claim() 메소드는 그 페이지들을 즉시 제어될 수 있도록 한다. 이로 인해, 당신의 서비스워커는 네트워크 또는 다른 서비스워커를 통해 정기적으로 로드되는 페이지들을 제어하게 된다.

+ +

Syntax

+ +
await clients.claim();
+
+ +

Parameters

+ +

None.

+ +

Returns

+ +

A {{jsxref("Promise")}} for void.

+ +

Example

+ +

다음 예시는 서비스워커의 "activate" 이벤트 리스너에서 claim() 를 사용하므로, fetch 들이 이 서비스워커를 통과하기 전에 동일한 스코프에서 로드된 클라이언트들은 다시 로드될 필요가 없다. .

+ +
self.addEventListener('activate', event => {
+  event.waitUntil(clients.claim());
+});
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#clients-claim', 'claim()')}}{{Spec2('Service Workers')}}Initial definition.
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.Clients.claim")}}

+
+ +

See also

+ + 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 +--- +

{{SeeCompatTable}}{{APIRef("Service Workers API")}}

+ +

The Clients interface provides access to {{domxref("Client")}} objects. Access it via {{domxref("ServiceWorkerGlobalScope", "self")}}.clients within a service worker.

+ +

Methods

+ +
+
{{domxref("Clients.get()")}}
+
Returns a {{jsxref("Promise")}} for a {{domxref("Client")}} matching a given {{domxref("Client.id", "id")}}.
+
{{domxref("Clients.matchAll()")}}
+
Returns a {{jsxref("Promise")}} for an array of {{domxref("Client")}} objects. An options argument allows you to control the types of clients returned. 
+
{{domxref("Clients.openWindow()")}}
+
Opens a new browser window for a given url and returns a {{jsxref("Promise")}} for the new {{domxref("WindowClient")}}.
+
{{domxref("Clients.claim()")}}
+
Allows an active service worker to set itself as the {{domxref("ServiceWorkerContainer.controller", "controller")}} for all clients within its {{domxref("ServiceWorkerRegistration.scope", "scope")}}. 
+
+ +

Examples

+ +

The following example shows an existing chat window or creates a new one when the user clicks a notification.

+ +
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!");
+  }());
+});
+
+ +

Specifications

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Service Workers', '#clients', 'Clients')}}{{Spec2('Service Workers')}}Initial definition
+ +

Browser compatibility

+ +
+ + +

{{Compat("api.Clients")}}

+
+ +

See also

+ + -- cgit v1.2.3-54-g00ecf