abstract fun observeDataSource(viewportStateDataObserver: ViewportStateDataObserver): Cancelable

Registers an observer to receive the cameras being generated by this ViewportState.

This method is commonly used by ViewportTransition implementations to obtain the target camera for transition animations. Transitions typically cannot start their animations until after the observer is invoked for the first time, so it's a good idea for ViewportState to invoke observer with the current camera if it's not too stale rather than waiting for the next camera change to occur. To increase the likelihood that a valid camera exists when an observer is registered, design ViewportState implementations so that they start updating their internal state prior to when they are passed to ViewportPlugin.transitionTo.

The caller may either cancel on the returned Cancelable or return false from ViewportStateDataObserver to indicate that it wishes to stop receiving updates. Following either of these events, implementations must no longer invoke ViewportStateDataObserver and must release all strong references to it.


a handle that cancels current observation.



observer that observe new viewport data.