Tink.Paginator (Tink v1.0.0)

Copy Markdown View Source

Stream-based cursor pagination helpers.

Usage

# Lazy stream — fetches pages on demand
Tink.Paginator.stream(fn page_token ->
  Tink.Transactions.list_transactions(client, page_token: page_token, page_size: 100)
end, items_key: "transactions")
|> Stream.filter(&(&1["type"] == "DEBIT"))
|> Enum.take(500)

Summary

Functions

Collect all pages eagerly and return {:ok, all_items}. Use stream/2 for large datasets.

Types

fetch_fn()

@type fetch_fn() :: (String.t() | nil -> {:ok, map()} | {:error, any()})

Functions

collect_all(fetch_fn, opts \\ [])

@spec collect_all(
  fetch_fn(),
  keyword()
) :: {:ok, list()} | {:error, any()}

Collect all pages eagerly and return {:ok, all_items}. Use stream/2 for large datasets.

stream(fetch_fn, opts \\ [])

@spec stream(
  fetch_fn(),
  keyword()
) :: Enumerable.t()