Pages

Pokaż przestarzałe

*Ta zawartość będzie dostępna wkrótce w wybranym przez ciebie języku.

Brak możliwości tworzenia
Bez replikacji

An object which is essentially a table of pages, each of which is a sorted list of the key/value pairs.

Przykłady kodu

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

Podsumowanie

Właściwości

  • Tylko do odczytu
    Bez replikacji
    Odczyt równoległy

    Whether or not the current page is the last page available.

Metody

  • Returns the items on the current page. The keys in the item are determined by the source of this object.

  • Iterates to the next page in the pages object, if possible.

Właściwości

IsFinished

Tylko do odczytu
Bez replikacji
Odczyt równoległy

Whether or not the current page is the last page available.

Metody

GetCurrentPage

Returns the items on the current page. The keys in the item are determined by the source of this object.


Zwroty

AdvanceToNextPageAsync

void
Wynik

Iterates to the next page in the pages object, if possible. The request limit is the same of the endpoint originally called.


Zwroty

void

Zdarzenia