---
title: "createLifecycleAwareWindowRecomposer"
description: "Create a [Lifecycle] and [window attachment][View.isAttachedToWindow]-aware [Recomposer] for this
[View] with the same behavior as [WindowRecomposerFactory.LifecycleAware].

[coroutineContext] will override any [CoroutineContext] elements from the default configuration
normally used for this content view. The default [CoroutineContext] contains
[AndroidUiDispatcher.CurrentThread]; this function should only be called from the UI thread of
this [View] or its intended UI thread if it is currently detached.

If [lifecycle] is `null` or not supplied the [LifecycleOwner] returned by
[findViewTreeLifecycleOwner] will be used; if a non-null [lifecycle] is not provided and a
ViewTreeLifecycleOwner is not present an [IllegalStateException] will be thrown.

The returned [Recomposer] will be [cancelled][Recomposer.cancel] when this [View] is detached
from a window or if its determined [Lifecycle] is [destroyed][Lifecycle.Event.ON_DESTROY].
Recomposition and associated [frame-based][MonotonicFrameClock] effects may be throttled or
paused while the [Lifecycle] is not at least [Lifecycle.State.STARTED]."
type: "function"
---

<div class='type'>Function</div>


<a id='references'></a>
<div class='sourceset sourceset-android'>Android</div>


```kotlin
fun View.createLifecycleAwareWindowRecomposer(
    coroutineContext: CoroutineContext = EmptyCoroutineContext,
    lifecycle: Lifecycle? = null,
): Recomposer
```


Create a `Lifecycle` and `window attachment`-aware `Recomposer` for this
`View` with the same behavior as `WindowRecomposerFactory.LifecycleAware`.

`coroutineContext` will override any `CoroutineContext` elements from the default configuration
normally used for this content view. The default `CoroutineContext` contains
`AndroidUiDispatcher.CurrentThread`; this function should only be called from the UI thread of
this `View` or its intended UI thread if it is currently detached.

If `lifecycle` is `null` or not supplied the `LifecycleOwner` returned by
`findViewTreeLifecycleOwner` will be used; if a non-null `lifecycle` is not provided and a
ViewTreeLifecycleOwner is not present an `IllegalStateException` will be thrown.

The returned `Recomposer` will be `cancelled` when this `View` is detached
from a window or if its determined `Lifecycle` is `destroyed`.
Recomposition and associated `frame-based` effects may be throttled or
paused while the `Lifecycle` is not at least `Lifecycle.State.STARTED`.



