Viewport State
ViewportState is used to observe the data source associated with the state and query the camera to keep updating according to current viewport data. ViewportState is also used by ViewportPlugin to orchestrate transitions to and from different states.
The observeDataSource allows ViewportTransition to consume a stream of camera updates from a target state while executing a transition.
The startUpdatingCamera and stopUpdatingCamera are invoked to tell the state that it should assume or relinquish control of the map's camera. These are typically used by ViewportPlugin itself after a successful transition into a state and when exiting a state, respectively.
Mapbox provides implementations of ViewportState that can be created and configured via methods on ViewportPlugin. Applications may also define their own implementations to handle advanced use cases not covered by the provided implementations.
ViewportState should generally pre-warm their data sources as soon as they are created to minimise delays when they become current. For this reason, only states that are current(or soon-to-be) needed should be kept alive so that unneeded resources(e.g. location services) can be released.
Note: Users are responsible to create the viewport states and keep a reference to these states for future operations.