Skip to main content
API Reference com.nianticspatial.nsdk.utils

FlowPollingManager

Manages Flow-based polling for session updates with automatic subscriber tracking and frame deduplication. This class abstracts the common pattern of: - Creating a MutableSharedFlow - Tracking active subscribers - Starting/stopping polling coroutines based on subscriber count - Deduplicating updates by frame ID or timestamp

Declaration

class FlowPollingManager<T>

Properties

NameTypeSummary
flowFlow<T>
Public Flow that automatically manages polling lifecycle.
frameIdExtractor((T) -> Long)?
Optional function to extract a frame ID from the polled result for deduplication. If provided, only new frames (different frame ID) will be emitted. If null, all results will be emitted.
pollFunction() -> T
Function to call during polling to get the latest data.
pollingIntervalMsLong
Interval between polling attempts in milliseconds.
timestampExtractor((T) -> Long)?
Optional function to extract a timestamp from the polled result for deduplication. If provided, only new timestamps (greater than last) will be emitted. If null and frameIdExtractor is also null, all results will be emitted.

Functions

NameTypeSummary
destroyvoid
Cleans up resources. Should be called when the session is destroyed.