Manage Properties and Settings¶
Reload a plan with new settings, apply or remove current settings, and track the plan loading status.
Overview¶
- The presenter (
IExpoFpPlanPresenter) exposes properties and methods to control settings of the current plan. - You can:
- Inspect current settings (link, params, provider).
- Reload the plan with new or previous settings.
- Dynamically update additional parameters, location provider, or message listener.
- Observe loading and readiness state via
planStatusFlow. - Observe errors that occur while the plan is operating via
planOperationalErrorFlow.
Step 1. Plan Properties¶
presenter.additionalParams // List<ExpoFpPlanParameter>, applied to the plan
presenter.planLink // ExpoFpLinkType, source of the plan
presenter.locationProvider // IExpoFpLocationProvider?, current provider
presenter.planStatusFlow // Flow<ExpoFpPlanStatus>, plan lifecycle state during loading, initialization, and work
presenter.planOperationalErrorFlow // Flow<ExpoFpError>, errors while the plan is operating (for example location provider failures)
Step 2. Reload Plan¶
Reload the plan with new settings.
If a parameter is null, the previous value will be reused.
presenter.reloadPlan(
planLink = ExpoFpLinkType.ExpoKey("YourExpoKey"), // or null
additionalParams = listOf(ExpoFpPlanParameter.NoOverlay(true), ExpoFpPlanParameter.HideHeaderLogo(true)), // or null
locationProvider = YourLocationProvider(), // or null
messageListener = YourListener() // or null
)
Important: If a plan is reloaded with a new
planLink, the link info is also updated in the correspondingExpoFpPreloadedPlanInfo(if the plan was preloaded).
Step 3. Change Current Settings¶
Additional parameters¶
presenter.additionalParams
// Example: listOf(ExpoFpPlanParameter.NoOverlay(true), ExpoFpPlanParameter.HideHeaderLogo(true))
val newParams = listOf(ExpoFpPlanParameter.NoOverlay(true), ExpoFpPlanParameter.HideHeaderLogo(true))
presenter.applyAdditionalParams(newParams)
presenter.removeAdditionalParams(listOf("noOverlay"))
Location provider¶
presenter.locationProvider // SomeLocationProvider or null
presenter.setLocationProvider(YourLocationProvider())
presenter.removeLocationProvider()
Message listener¶
// Keep a strong reference to the listener; the SDK does not retain it.
val listener = YourPlanMessageListener()
presenter.setMessageListener(listener)
presenter.removeMessageListener()
Custom message handler¶
presenter.setMessageHandler(yourHandler, "callbackName")
presenter.removeMessageHandler("callbackName")
Step 4. Monitor Plan Status¶
Observe planStatusFlow to react to lifecycle changes.
lifecycleScope.launchWhenStarted {
presenter.planStatusFlow.collect { status ->
when (status) {
is ExpoFpPlanStatus.Initialization -> { /* starting */ }
is ExpoFpPlanStatus.Loading -> { /* status.percentage */ }
is ExpoFpPlanStatus.Ready -> { /* ready */ }
is ExpoFpPlanStatus.Error -> { /* status.error */ }
}
}
}
Observe planOperationalErrorFlow to react to errors that occur while the plan is operating, for example
location provider failures. These errors do not change planStatusFlow, so the plan keeps loading
and remains usable. The flow does not replay past errors, so make sure the collector is active
before attaching the plan view. A collector that only starts in the STARTED state, for example
launchWhenStarted, can miss an error reported during attach.
import kotlinx.coroutines.CoroutineStart
// Subscribe before attaching the plan view so early errors are not missed.
lifecycleScope.launch(start = CoroutineStart.UNDISPATCHED) {
presenter.planOperationalErrorFlow.collect { error ->
// for example show a snackbar: the blue dot is unavailable
}
}
val expoView = ExpoFpView(this).apply { attachPresenter(presenter) }
setContentView(expoView)