Pages

顯示已棄用項目

*此內容是使用 AI(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

()
暫停

如果可能,會循環到頁面對物件的下一頁。請求限制與最初呼叫的端點相同。


返回

()

活動