diff --git a/formula-android/src/main/java/com/instacart/formula/android/ActivityStore.kt b/formula-android/src/main/java/com/instacart/formula/android/ActivityStore.kt index 0452147d..a565d255 100644 --- a/formula-android/src/main/java/com/instacart/formula/android/ActivityStore.kt +++ b/formula-android/src/main/java/com/instacart/formula/android/ActivityStore.kt @@ -14,13 +14,15 @@ import io.reactivex.rxjava3.disposables.Disposable * configuration changes. Check [com.instacart.formula.android.StreamConfigurator] for utility methods. * @param configureActivity This is invoked as part of [com.instacart.formula.FormulaAndroid.onPreCreate]. You can * use this callback to inject the activity. - * @param onRenderFragmentState This is invoked after [FragmentState] has been updated. + * @param onPreRenderFragmentState This is invoked before [FragmentState] is applied. + * @param onRenderFragmentState This is invoked after [FragmentState] has been applied. * @param onFragmentLifecycleEvent This is callback for when a fragment is added or removed. */ class ActivityStore( val fragmentStore: FragmentStore = FragmentStore.EMPTY, val streams: (StreamConfigurator.() -> Disposable)? = null, val configureActivity: ((Activity) -> Unit)? = null, + val onPreRenderFragmentState: ((Activity, FragmentState) -> Unit)? = null, val onRenderFragmentState: ((Activity, FragmentState) -> Unit)? = null, val onFragmentLifecycleEvent: ((FragmentLifecycleEvent) -> Unit)? = null ) diff --git a/formula-android/src/main/java/com/instacart/formula/android/internal/ActivityManager.kt b/formula-android/src/main/java/com/instacart/formula/android/internal/ActivityManager.kt index af00e8d9..09776678 100644 --- a/formula-android/src/main/java/com/instacart/formula/android/internal/ActivityManager.kt +++ b/formula-android/src/main/java/com/instacart/formula/android/internal/ActivityManager.kt @@ -57,6 +57,7 @@ internal class ActivityManager( val renderView = fragmentRenderView ?: throw callOnPreCreateException(activity) uiSubscription = delegate.fragmentState().subscribe { + store.onPreRenderFragmentState?.invoke(activity, it) renderView.render(it) store.onRenderFragmentState?.invoke(activity, it) }