Skip to content

Commit

Permalink
add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
vkatz committed Nov 4, 2024
1 parent 72a92a3 commit 8bf5c08
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tiamat/src/commonMain/kotlin/com/composegears/tiamat/Extension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,27 @@ package com.composegears.tiamat

import androidx.compose.runtime.Composable

/**
* Extension base class
*/
public abstract class Extension<Args> {

@Composable
internal fun ExtensionContent(scope: NavDestinationScope<Args>) {
scope.content()
}

/**
* The content of extension
*/
@Composable
public abstract fun NavDestinationScope<Args>.content()
}

/**
* Provides an attached extension of defined type
*
* @return extension or null if the ext of this type is not attached
*/
public inline fun <reified P : Extension<*>> NavDestination<*>.ext(): P? =
extensions.firstOrNull { it is P } as? P?

0 comments on commit 8bf5c08

Please sign in to comment.