Skip to content

Commit

Permalink
docs: rememberCloseableOnRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
hoc081098 committed Feb 7, 2024
1 parent b00289f commit ecbc7a2
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.hoc081098.solivagant.navigation

import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisallowComposableCalls
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
Expand All @@ -30,6 +29,10 @@ import kotlin.reflect.KClass
*
* The [Closeable] will be created by [factory] once at the first access.
* It will be closed when the [route] is removed from the back stack.
*
* @param route The route to remember the [Closeable] on.
* @param type The type of [Closeable].
* @param factory The factory to create the [Closeable].
*/
@OptIn(DelicateNavigationApi::class)
@Composable
Expand All @@ -55,9 +58,12 @@ public fun <T : Closeable> rememberCloseableOnRoute(
*
* The [Closeable] will be created by [factory] once at the first access.
* It will be closed when the [route] is removed from the back stack.
*
* @param route The route to remember the [Closeable] on.
* @param factory The factory to create the [Closeable].
*/
@Composable
public inline fun <reified T : Closeable> rememberCloseableOnRoute(
route: BaseRoute,
noinline factory: @DisallowComposableCalls () -> T,
noinline factory: () -> T,
): T = rememberCloseableOnRoute(route, T::class, factory)

0 comments on commit ecbc7a2

Please sign in to comment.