catchBoomerangWithLifecycleEvent

fun Fragment.catchBoomerangWithLifecycleEvent(key: String, lifecycleEvent: Lifecycle.Event = Lifecycle.Event.ON_START, catcher: BoomerangCatcher)

Extension function for Fragment that sets up a lifecycle observer to catch a boomerang value when a specific lifecycle event occurs. This function should be called in the Fragment's onCreate method to not multiply the observers. The observer will try to catch the value when the specified lifecycle event occurs and will remove itself when the fragment is destroyed. Example usage

Parameters

key

The key to try to catch the value for

lifecycleEvent

The lifecycle event that triggers the catch attempt (default is ON_START)

catcher

The BoomerangCatcher to use for catching the value

Throws

if the lifecycleEvent is not ON_START or ON_RESUME

if called after Fragment's onCreate, if the Fragment is not attached to an Activity, if the Activity does not implement BoomerangStoreHost, or if the BoomerangStore is not initialized


inline fun Fragment.catchBoomerangWithLifecycleEvent(key: String, lifecycleEvent: Lifecycle.Event = Lifecycle.Event.ON_START, crossinline catcher: (Boomerang) -> Unit)

Extension function for Fragment that sets up a lifecycle observer to catch a boomerang value when a specific lifecycle event occurs. This is an inline version that accepts a lambda function instead of a BoomerangCatcher. This function should be called in the Fragment's onCreate method to not multiply the observers. Example usage

Parameters

key

The key to try to catch the value for

lifecycleEvent

The lifecycle event that triggers the catch attempt (default is ON_START)

catcher

Lambda function that will be called with the caught Boomerang value

Throws

if the lifecycleEvent is not ON_START or ON_RESUME

if called after Fragment's onCreate, if the Fragment is not attached to an Activity, if the Activity does not implement BoomerangStoreHost, or if the BoomerangStore is not initialized