LifecycleStartEffect

fun LifecycleStartEffect(key1: Any?, lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current, effects: LifecycleStartStopEffectScope.() -> LifecycleStopOrDisposeEffectResult)(source)

Schedule a pair of effects to run when the Lifecycle receives either a Lifecycle.Event.ON_START or Lifecycle.Event.ON_STOP (or any new unique value of key1). The ON_START effect will be the body of the effects block and the ON_STOP effect will be within the (onStopOrDispose clause)LifecycleStartStopEffectScope.onStopOrDispose:

LifecycleStartEffect(lifecycleOwner) {
// add ON_START effect here

onStopOrDispose {
// add clean up for work kicked off in the ON_START effect here
}
}

A LifecycleStartEffect must include an onStopOrDispose clause as the final statement in its effects block. If your operation does not require an effect for both Lifecycle.Event.ON_START and Lifecycle.Event.ON_STOP, a LifecycleEventEffect should be used instead.

A LifecycleStartEffect's key is a value that defines the identity of the effect. If the key changes, the LifecycleStartEffect must dispose its current effects and reset by calling effects again. Examples of keys include:

  • Observable objects that the effect subscribes to

  • Unique request parameters to an operation that must cancel and retry if those parameters change

This function uses a Lifecycle.Observer to listen for when LifecycleStartEffect enters the composition and the effects will be launched when receiving a Lifecycle.Event.ON_START or Lifecycle.Event.ON_STOP event, respectively. If the LifecycleStartEffect leaves the composition prior to receiving an Lifecycle.Event.ON_STOP event, onStopOrDispose will be called to clean up the work that was kicked off in the ON_START effect.

This function should not be used to launch tasks in response to callback events by way of storing callback data as a Lifecycle.State in a MutableState. Instead, see currentStateAsState to obtain a State that may be used to launch jobs in response to state changes.

Parameters

key1

The unique value to trigger recomposition upon change

lifecycleOwner

The lifecycle owner to attach an observer

effects

The effects to be launched when we receive the respective event callbacks


fun LifecycleStartEffect(key1: Any?, key2: Any?, lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current, effects: LifecycleStartStopEffectScope.() -> LifecycleStopOrDisposeEffectResult)(source)

Schedule a pair of effects to run when the Lifecycle receives either a Lifecycle.Event.ON_START or Lifecycle.Event.ON_STOP (or any new unique value of key1 or key2). The ON_START effect will be the body of the effects block and the ON_STOP effect will be within the (onStopOrDispose clause)LifecycleStartStopEffectScope.onStopOrDispose:

LifecycleStartEffect(lifecycleOwner) {
// add ON_START effect here

onStopOrDispose {
// add clean up for work kicked off in the ON_START effect here
}
}

A LifecycleStartEffect must include an onStopOrDispose clause as the final statement in its effects block. If your operation does not require an effect for both Lifecycle.Event.ON_START and Lifecycle.Event.ON_STOP, a LifecycleEventEffect should be used instead.

A LifecycleStartEffect's key is a value that defines the identity of the effect. If a key changes, the LifecycleStartEffect must dispose its current effects and reset by calling effects again. Examples of keys include:

  • Observable objects that the effect subscribes to

  • Unique request parameters to an operation that must cancel and retry if those parameters change

This function uses a Lifecycle.Observer to listen for when LifecycleStartEffect enters the composition and the effects will be launched when receiving a Lifecycle.Event.ON_START or Lifecycle.Event.ON_STOP event, respectively. If the LifecycleStartEffect leaves the composition prior to receiving an Lifecycle.Event.ON_STOP event, onStopOrDispose will be called to clean up the work that was kicked off in the ON_START effect.

This function should not be used to launch tasks in response to callback events by way of storing callback data as a Lifecycle.State in a MutableState. Instead, see currentStateAsState to obtain a State that may be used to launch jobs in response to state changes.

Parameters

key1

A unique value to trigger recomposition upon change

key2

A unique value to trigger recomposition upon change

lifecycleOwner

The lifecycle owner to attach an observer

effects

The effects to be launched when we receive the respective event callbacks


fun LifecycleStartEffect(key1: Any?, key2: Any?, key3: Any?, lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current, effects: LifecycleStartStopEffectScope.() -> LifecycleStopOrDisposeEffectResult)(source)

Schedule a pair of effects to run when the Lifecycle receives either a Lifecycle.Event.ON_START or Lifecycle.Event.ON_STOP (or any new unique value of key1 or key2 or key3). The ON_START effect will be the body of the effects block and the ON_STOP effect will be within the (onStopOrDispose clause)LifecycleStartStopEffectScope.onStopOrDispose:

LifecycleStartEffect(lifecycleOwner) {
// add ON_START effect here

onStopOrDispose {
// add clean up for work kicked off in the ON_START effect here
}
}

A LifecycleStartEffect must include an onStopOrDispose clause as the final statement in its effects block. If your operation does not require an effect for both Lifecycle.Event.ON_START and Lifecycle.Event.ON_STOP, a LifecycleEventEffect should be used instead.

A LifecycleStartEffect's key is a value that defines the identity of the effect. If a key changes, the LifecycleStartEffect must dispose its current effects and reset by calling effects again. Examples of keys include:

  • Observable objects that the effect subscribes to

  • Unique request parameters to an operation that must cancel and retry if those parameters change

This function uses a Lifecycle.Observer to listen for when LifecycleStartEffect enters the composition and the effects will be launched when receiving a Lifecycle.Event.ON_START or Lifecycle.Event.ON_STOP event, respectively. If the LifecycleStartEffect leaves the composition prior to receiving an Lifecycle.Event.ON_STOP event, onStopOrDispose will be called to clean up the work that was kicked off in the ON_START effect.

This function should not be used to launch tasks in response to callback events by way of storing callback data as a Lifecycle.State in a MutableState. Instead, see currentStateAsState to obtain a State that may be used to launch jobs in response to state changes.

Parameters

key1

The unique value to trigger recomposition upon change

key2

The unique value to trigger recomposition upon change

key3

The unique value to trigger recomposition upon change

lifecycleOwner

The lifecycle owner to attach an observer

effects

The effects to be launched when we receive the respective event callbacks


fun LifecycleStartEffect(vararg keys: Any?, lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current, effects: LifecycleStartStopEffectScope.() -> LifecycleStopOrDisposeEffectResult)(source)

Schedule a pair of effects to run when the Lifecycle receives either a Lifecycle.Event.ON_START or Lifecycle.Event.ON_STOP (or any new unique value of keys). The ON_START effect will be the body of the effects block and the ON_STOP effect will be within the (onStopOrDispose clause)LifecycleStartStopEffectScope.onStopOrDispose:

LifecycleStartEffect(lifecycleOwner) {
// add ON_START effect here

onStopOrDispose {
// add clean up for work kicked off in the ON_START effect here
}
}

A LifecycleStartEffect must include an onStopOrDispose clause as the final statement in its effects block. If your operation does not require an effect for both Lifecycle.Event.ON_START and Lifecycle.Event.ON_STOP, a LifecycleEventEffect should be used instead.

A LifecycleStartEffect's key is a value that defines the identity of the effect. If a key changes, the LifecycleStartEffect must dispose its current effects and reset by calling effects again. Examples of keys include:

  • Observable objects that the effect subscribes to

  • Unique request parameters to an operation that must cancel and retry if those parameters change

This function uses a Lifecycle.Observer to listen for when LifecycleStartEffect enters the composition and the effects will be launched when receiving a Lifecycle.Event.ON_START or Lifecycle.Event.ON_STOP event, respectively. If the LifecycleStartEffect leaves the composition prior to receiving an Lifecycle.Event.ON_STOP event, onStopOrDispose will be called to clean up the work that was kicked off in the ON_START effect.

This function should not be used to launch tasks in response to callback events by way of storing callback data as a Lifecycle.State in a MutableState. Instead, see currentStateAsState to obtain a State that may be used to launch jobs in response to state changes.

Parameters

keys

The unique values to trigger recomposition upon changes

lifecycleOwner

The lifecycle owner to attach an observer

effects

The effects to be launched when we receive the respective event callbacks