Since context receiver is dropped. how can i achie...
# compose
s
Since context receiver is dropped. how can i achieve this? I use context receiver to wrap things in a specific business context, like logger, touch, gesture detector etc. the bellow example i use ComapanyBussinessScope scope context to make the log function available for the button
Copy code
context(ComapanyBussinessScope)
@Composable
fun SPrimaryButton(
    modifier: Modifier = Modifier,
    onClick: () -> Unit,
    enabled: Boolean = true,
    contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    isLoading: Boolean = false,
    content: @Composable RowScope.() -> Unit,
) {

    Button(
        modifier = modifier,
        onClick = {
            // log function is from ComapanyBussinessScope 
            log("Button $content clicked")
            if (!isLoading)
                onClick.invoke()
        },
        enabled = enabled,
        shape = ButtonDefaults.shape,
        colors = ButtonDefaults.buttonColors(),
        elevation = ButtonDefaults.buttonElevation(),
        border = null,
        contentPadding = contentPadding,
        interactionSource = interactionSource
    ) {
        if (isLoading)
            CircularProgressIndicator(
                modifier = Modifier
                    .size(24.dp),
                color = MaterialTheme.colorScheme.onPrimary,
            )
        else
            content()
    }
}
s
What is dropped? Context receivers? The KEEP is still up and the feature will still land in Kotlin, only slightly altered and named context parameters now https://github.com/Kotlin/KEEP/issues/367 For now just continue using what you are using already.
☝️ 1
☝🏾 1