From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../archive/b2g_os/api/settingslock/index.html | 55 +++++++++++++++ .../archive/b2g_os/api/settingslock/set/index.html | 80 ++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 files/zh-cn/archive/b2g_os/api/settingslock/index.html create mode 100644 files/zh-cn/archive/b2g_os/api/settingslock/set/index.html (limited to 'files/zh-cn/archive/b2g_os/api/settingslock') diff --git a/files/zh-cn/archive/b2g_os/api/settingslock/index.html b/files/zh-cn/archive/b2g_os/api/settingslock/index.html new file mode 100644 index 0000000000..50f05a7966 --- /dev/null +++ b/files/zh-cn/archive/b2g_os/api/settingslock/index.html @@ -0,0 +1,55 @@ +--- +title: SettingsLock +slug: Archive/B2G_OS/API/SettingsLock +tags: + - API + - B2G + - Firefox OS + - NeedsTranslation + - Non-standard + - Settings + - TopicStub +translation_of: Archive/B2G_OS/API/SettingsLock +--- + + +
+

This API is available on Firefox OS for internal applications only.

+
+ +

The SettingsLock interface represents a lock on settings. it allows a script to modify settings asynchronously, but in a safe way: ordering is guaranteed and the no other script will modify the settings until the modification are done (the next lock objects will start processing after it has been closed).

+ +

Each call to SettingsManager.createLock() create a new SettingsLock object.

+ +

All SettingsLock objects are kept in a queue of active locks. When a SettingsLock object is created it's placed at the end of the queue. Calls to get/set places a request against the lock on which it's called. Requests run asynchronously and in the order they are placed against a lock. When the last request for a lock is run, and  the success/error event against it has been fired, the lock is removed from the queue and the next lock start to be processed.

+ +

Properties

+ +
+
SettingsLock.closed
+
Indicates if the lock is no longer the active lock (true) or if it's still the active lock (false)
+
+ +

Methods

+ +
+
SettingsLock.set()
+
Allows to change the values of a set of settings. This method is asychronous and return a DOMRequest object.
+
SettingsLock.get()
+
Allows to retrieve the value of a given setting. This method is asychronous and return a DOMRequest object.
+
SettingsLock.clear()
+
Clears any action that have not been done yet (remember that get and set are asynchronous). This method is added for testing and it deletes the whole settings DB!
+
+ +

Specification

+ +

Not part of any specification yet; however, this API will be discuss at W3C as part of the System Applications Working Group.

+ +

See also

+ + diff --git a/files/zh-cn/archive/b2g_os/api/settingslock/set/index.html b/files/zh-cn/archive/b2g_os/api/settingslock/set/index.html new file mode 100644 index 0000000000..2203fc1169 --- /dev/null +++ b/files/zh-cn/archive/b2g_os/api/settingslock/set/index.html @@ -0,0 +1,80 @@ +--- +title: SettingsLock.set() +slug: Archive/B2G_OS/API/SettingsLock/set +translation_of: Archive/B2G_OS/API/SettingsLock/set +--- + + + + + + +
+

此API在 Firefox OS 上仅可供 内部程序  使用.

+
+ + + +

摘要

+ +

这个方法用来更改一或多个已提供的设置的值。

+ +

此方法是异步的,返回一个 DOMRequest 对象,用于检测更改何时完成(或是否发生错误),并在更改完成后根据需要执行操作。

+ +

语法

+ +
SettingsLock.set(settings);
+ +

参数

+ +
+
settings
+
一个包含了一组键值对的对象,其中每个键表示给定的设置的字符串名称。可能的字符串的确切列表取决于设备。每个Gaia构建可以有自己的设置列表,有关这些字符串的最新列表,请查看 the Gaia source code.
+
+ +

示例

+ +

这个示例用来打开设备的WIFI。

+ +
var lock = navigator.mozSettings.createLock();
+var result = lock.set({
+  'wifi.enabled': true
+});
+
+result.onsuccess = function () {
+  console.log("The setting has been changed");
+}
+
+result.onerror = function () {
+  console.log("An error occure, the setting remain unchanged");
+}
+
+ +

规范

+ +

这目前还不是任何规范的一部分; 然而, 此 API 将会作为 System Applications Working Group 的一部分参与W3C的讨论。

+ +

其他

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