PollingCollector
public class PollingCollector : SingleValueCollector, Submittable, ContinueNodeAware, DaVinciAware, Closeable, @unchecked Sendable
A collector that handles asynchronous polling operations in DaVinci authentication flows.
Used for scenarios that require waiting for user action on another device or channel, such as push notification authentication, QR code scanning, or email verification.
Polling Modes
Simple Polling Mode
When pollChallengeStatus is false or challenge is empty: waits for pollInterval ms,
decrements retriesAllowed, emits .complete(status: "continue") while retries remain,
and .timedOut when retries are exhausted.
Challenge Status Polling Mode
When pollChallengeStatus is true and challenge is non-empty: repeatedly POSTs to
{baseUrl}/davinci/user/credentials/challenge/{challenge}/status until the challenge
completes, expires, times out, or an error occurs.
Value Assignment
The value property is updated automatically before each terminal status is yielded:
.complete→ the server status string (e.g."approved"or"continue").timedOut→"timedOut".expired→"expired".error→"error".continue→"continue"
-
The continue node providing configuration context (links, interactionId) for challenge polling. Declared
weakto break the retain cycle:ContinueNode → PollingCollector → ContinueNode. The node is kept alive by the view layer that is currently displaying it, so the weak reference is always valid for the duration of an active polling session.Declaration
Swift
public weak var continueNode: ContinueNode? { get set }
-
The DaVinci workflow instance providing access to the HTTP client.
Declaration
Swift
public var davinci: DaVinci?
-
Polling interval in milliseconds between each attempt. Default:
2000.Declaration
Swift
public private(set) var pollInterval: Int { get } -
Maximum number of polling attempts before timing out. Default:
60.Declaration
Swift
public private(set) var pollRetries: Int { get } -
Whether to actively poll the server endpoint for challenge completion. Default:
false.Declaration
Swift
public private(set) var pollChallengeStatus: Bool { get } -
The challenge identifier used to construct the polling endpoint URL. Default:
"".Declaration
Swift
public private(set) var challenge: String { get } -
Remaining attempts for simple polling mode. Initialized from
pollRetriesand decremented on each interval.Declaration
Swift
public var retriesAllowed: Int
-
Declaration
Swift
public required init(with json: [String : Any])
-
Returns the event type for submission.
Declaration
Swift
public func eventType() -> String
-
Starts polling and returns an
AsyncStreamofPollingStatusupdates.The stream finishes when polling reaches a terminal state (
.complete,.timedOut,.expired, or.error). Thevalueproperty is updated automatically before each status is yielded.Declaration
Swift
public func poll() -> AsyncStream<PollingStatus>
-
Thread-safe read of
valuefor form submission.Declaration
Swift
public override func payload() -> String?
-
Declaration
Swift
public func close()
View on GitHub