# FlowPollingManager Source: https://www.nianticspatial.com/docs/api/kotlin/com.nianticspatial.nsdk.utils.FlowPollingManager/ FlowPollingManager --- ## Declaration class FlowPollingManager ## Summary 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 --- ## Constructors constructor(pollingIntervalMs: Long, pollFunction: () -> T, frameIdExtractor: ((T) -> Long)? = null, timestampExtractor: ((T) -> Long)? = null) ### Parameters | Name | Type | Summary | | --- | --- | --- | | pollingIntervalMs | Long | - | | pollFunction | () -> T | - | | frameIdExtractor | ((T) -> Long)? | - | | timestampExtractor | ((T) -> Long)? | - | --- ## Properties | Name | Type | Summary | | --- | --- | --- | | flow | Flow | Public Flow that automatically manages polling lifecycle.Polls on [Dispatchers.Default] while at least one collector is subscribed; each collectorreceives values in its own coroutine context. A session's flows can be collected before thesession is acquired and across close()/acquire(): they emit only while it is acquired.After [destroy] (when the NSDKSession is closed) every collection completes, and a new onecompletes at once. | --- ## Functions | Name | Type | Summary | | --- | --- | --- | | createForNSDKResult | FlowPollingManager> | Creates a FlowPollingManager specifically for ARDKResult types, reducing boilerplate code.This helper automatically handles ARDKResult.Success and ARDKResult.Error cases:- Success results are deduplicated based on frameIdExtractor- Error results are emitted when they differ from the previous result, so a change fromone error to another is reported, but the same error is not repeated on every poll | | destroy | void | Ends polling for good and completes every collection of [flow], current and future. Calledwhen the NSDKSession is closed, after which the feature can never emit again; a collector thatoutlives the session then finishes instead of waiting forever. Waits for a poll in flight. | ---