Skip to content

Unclear how to resume iterating with PageIterator if the callback returns False #688

Open
@jasonjoh

Description

@jasonjoh

In other SDKs, the iterator class typically has a Resume method to restart the iteration where it left off, and a corresponding State property to check if the iterator has completed or not. For example, in .NET:

var pageIterator = PageIterator<Message, MessageCollectionResponse>
    .CreatePageIterator(
        graphClient,
        messages,
        (msg) =>
        {
            Console.WriteLine(msg.Subject);
            count++;
            // If we've iterated over the limit,
            // stop the iteration by returning false
            return count < pauseAfter;
        });

await pageIterator.IterateAsync();

while (pageIterator.State != PagingState.Complete)
{
    Console.WriteLine("Iteration paused for 5 seconds...");
    await Task.Delay(5000);
    // Reset count
    count = 0;
    await pageIterator.ResumeAsync();
}

Is there a way to do this in this SDK?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:p2Medium. For a p2 bug, generally have a work-around. Bug SLA <=30 days

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions