Storage Documentation

Structure Loop

public struct Loop<Next: Sendable, Content: SingleEndpoint>  

A struct defining a custom endpoint implementation handling a paginated request.

%171 Loop Loop LoopEndpoint LoopEndpoint Loop->LoopEndpoint

Conforms To

LoopEndpoint

Nested Type Aliases

Output

public typealias Output = Content.Output

The associated output type.

Initializers

init(starting​At:​content:​next:​)

public init(
        startingAt first: Next,
        @EndpointBuilder content: @escaping (_ offset: Int, _ input: Next) -> Content,
        next: @escaping (_ offset: Int, _ output: Output) throws -> NextAction<Next>
    )  

Init.

Parameters

first Next

The starter Next for the pagination.

request

The actual endpoint request.

next @escaping (_ offset:​ Int, _ output:​ Output) throws -> Next​Action<Next>

The next page mapper.

init(starting​At:​content:​next:​)

public init(
        startingAt first: Next,
        @EndpointBuilder content: @escaping (Next) -> Content,
        next: @escaping (Output) throws -> NextAction<Next>
    )  

Init.

Parameters

first Next

The starter Next for the pagination.

request

The actual endpoint request.

next @escaping (Output) throws -> Next​Action<Next>

The next page mapper.

Methods

resolve(with:​)

public func resolve<R: EndpointResolver>(with session: R) -> AsyncThrowingStream<Output, any Error>  

Fetch responses, from a given Input and URLSession.

Parameters

session R

The EndpointResolver used to fetch the response.

Returns

Some AsyncStream.

resolve(with:​)

public func resolve<R: EndpointResolver>(with session: R) -> AnyPublisher<Output, any Error>  

Fetch responses, from a given Input and URLSession.

Parameters

session R

The EndpointResolver used to fetch the response.

Returns

Some AsyncStream.