パッケージ、リポジトリ、アプリカテゴリを検索

GitHub リポジトリisoos/service_worker

service_worker

Dart のサービスワーカー API

service_worker のプロジェクト画像
スター
37
フォーク
18
最終プッシュ(UTC)
2024/04/11
プロジェクト状態
公開中

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

Service Worker API for Dart

Dart-y wrappers for the ServiceWorker APIs.

Warning: the API is experimental, and subject to change.

Service Workers

A service worker is an event-driven worker registered against an origin and a path. It takes the form of a JavaScript file that can control the web page/site it is associated with, intercepting and modifying navigation and resource requests, and caching resources in a very granular fashion to give you complete control over how your app behaves in certain situations (the most obvious one being when the network is not available.)

A service worker is run in a worker context: it therefore has no DOM access, and runs on a different thread to the main JavaScript that powers your app, so it is not blocking. It is designed to be fully async; as a consequence, APIs such as synchronous XHR and localStorage can't be used inside a service worker.

Quickstart

Register the Service Worker from your application script, like in example/web/main.dart:

import 'package:service_worker/window.dart' as sw;

void main() {
  if (sw.isSupported) {
    sw.register('sw.dart.js');
  } else {
    print('ServiceWorkers are not supported.');
  }
}

Write the Service Worker in a separate script, like in example/web/sw.dart:

import 'package:service_worker/service_worker.dart';

void main(List<String> args) {
  onInstall.listen((event) {
    print('ServiceWorker installed.');
  });
}

Limitation

You need to force dart2js compilation for service worker to work during debug mode. See build.yaml in the example folder.

István Soós GitHub avatar
GitHub 作者

István Soós ↗

software engineer

@agilordBudapest, Hungary公式サイト ↗
言語DartHTMLCSS

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 2 件

  • js>=0.6.1 <2.0.0
  • lints開発用^3.0.0

プロジェクトに合うリポジトリを選ぶには?

用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。

  1. 名前・作者・説明で検索し、技術トピックで絞り込みます。
  2. スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
  3. 利用前に GitHub で README、ライセンス、Issues を確認します。

情報源と管理

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗