DownloadList 编辑

A DownloadList object represents a collection of Download objects that can be viewed and managed by the user interface, and persisted across sessions.

A reference to a DownloadList object can be obtained using the Downloads.getList() function.

Method overview

Promise<Array<Download>> getAll();
Promise add(Download aDownload);
Promise remove(Download aDownload);
Promise addView(ObjectaView);
Promise removeView(ObjectaView);
void removeFinished([optional] Function aFilterFn);

Methods

getAll()

Retrieves a snapshot of the downloads that are currently in the list. The returned array does not change when downloads are added or removed, though the Download objects it contains are still updated in real time.

Promise<Array<Download>> getAll();
Parameters

None.

Promise resolves to

An array of Download objects.

add()

Adds a new download to the end of the items list.

Note: When a download is added to the list, its onchange event is registered by the list, thus it cannot be used to monitor the download. To receive change notifications for downloads that are added to the list, use the addView() method to register for onDownloadChanged notifications.
Promise add(
  Download aDownload
);
Parameters
aDownload
The Download object to add.
Promise resolves to

undefined when the download has been added.

remove()

Removes a download from the list. If the download was already removed, this method has no effect.

Promise remove(
  Download aDownload
);
Parameters
aDownload
The Download object to remove.
Promise resolves to

undefined when the download has been removed.

addView()

Adds a view that will be notified of changes to downloads. The newly added view will receive onDownloadAdded notifications for all the downloads that are already in the list.

Promise addView(
  Object aView
);
Parameters
aView
The view object to add. The following methods may be defined:
  • onDownloadAdded: Optional This function is called with a single Download argument, after the download is added to the end of the list.
  • onDownloadChanged: Optional This function is called with a single Download argument, after the properties of the download change.
  • onDownloadRemoved: Optional This function is called with a single Download argument, after the download is removed from the list.
Promise resolves to

undefined when the view has been registered and all the onDownloadAdded notifications for the existing downloads have been sent.

removeView()

Removes a view that was previously added using addView().

Promise removeView(
  Object aView
);
Parameters
aView Optional
The view object to remove.
Promise resolves to

undefined when the view has been removed. At this point, the removed view will not receive any more notifications.

removeFinished()

Removes downloads from the list that have finished, have failed, or have been canceled without keeping partial data. A filter function may be specified to remove only a subset of those downloads.

This method finalizes each removed download, ensuring that any partially downloaded data associated with it is also removed.

Promise removeFinished(
  Function aFilterFn
);
Parameters
aFilterFn
The filter function is called with each download as its only argument, and should return true to remove the download and false to keep it. This parameter may be null or omitted to have no additional filter.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:71 次

字数:8218

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文