发起方 XXX
通过使用ResultRecipient参数来实现注册回调监听。
@Destination
@Composable
fun XXX(
navigator: DestinationsNavigator = EmptyDestinationsNavigator,
result: ResultRecipient<YYYDestination, String> = EmptyResultRecipient(),
) {
result.onNavResult {
EchoLog.log("resultRecipient", it)
when (it) {
is NavResult.Canceled -> {}
is NavResult.Value -> {
//----
}
}
}
}
返回方YYY
通过ResultBackNavigator来实现数据回传
@Destination
@Composable
fun YYY(
navigator: DestinationsNavigator = EmptyDestinationsNavigator,
resultBackNavigator: ResultBackNavigator<String> = EmptyResultBackNavigator()
) {
//在需要返回的地方
resultBackNavigator.navigateBack("ans")
}
网友评论