Pages

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

无法创建
未复制

一个实体,其实际上是一张页表,每个都是排序列表的键/值对。

代码示例

When each page in a Pages object contains a list of multiple items, this iterator function and its helper may be useful.

Pages Iterator

-- Reformat pages as tables
local function pagesToTable(pages)
local items = {}
while true do
table.insert(items, pages:GetCurrentPage())
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
end
return items
end
local function iterPageItems(pages)
local contents = pagesToTable(pages)
-- Track the current page number starting at 1
local pageNum = 1
-- Get last page number so we don't iterate over it
local lastPageNum = #contents
-- for resumes this coroutine until there's nothing to go through
return coroutine.wrap(function()
-- Loop until page number is greater than last page number
while pageNum <= lastPageNum do
-- Go through all the entries of the current page
for _, item in ipairs(contents[pageNum]) do
-- Pause loop to let developer handle entry and page number
coroutine.yield(item, pageNum)
end
pageNum += 1
end
end)
end
-- Using the iterPageItems function to iterate through the pages of a catalog search
local AvatarEditorService = game:GetService("AvatarEditorService")
local parameters = CatalogSearchParams.new()
parameters.SearchKeyword = "Hair"
local catalogPages = AvatarEditorService:SearchCatalog(parameters)
for item, pageNumber in iterPageItems(catalogPages) do
print(item, pageNumber)
end

概要

属性

  • 只读
    未复制
    读取并联

    当前页是否为可用的最后一页。

方法

属性

IsFinished

只读
未复制
读取并联

当前页是否为可用的最后一页。

方法

GetCurrentPage

返回当前页面上的项目。该项目的键由此对象的来源决定。


返回

AdvanceToNextPageAsync

()
暂停

如果可能,循环到页对象的下一页。请求限制与最初调用的端点相同。


返回

()

活动