-
-
Save saqib-github-commits/4aa8d7b941d294b31a58b1357940a387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compositionLocal created for AnalyticsLogger | |
val LocalAnalyticsLogger = staticCompositionLocalOf<AnalyticsLogger> { | |
DummyAnalyticsLogger() | |
} | |
//a helper compsable function created which is using compositionLocal LocalAnalyticsLogger | |
// created above and assigning default value | |
// ocalAnalyticsLogger.current gets current assigned value of AnalyticsLogger which will be | |
// DummyAnalyticsLogger unless a new implementation is provided | |
@Composable | |
fun LogScreenVisited( | |
screenName: String, | |
analyticsLogger: AnalyticsLogger = LocalAnalyticsLogger.current | |
) = LaunchedEffect(Unit) { | |
analyticsLogger.logScreenVisited(screenName) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment